diff options
author | Florian Westphal <fwestphal@astaro.com> | 2011-02-17 05:32:38 -0500 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2011-02-17 05:32:38 -0500 |
commit | d503b30bd648b3cb4e5f50b65d27e389960cc6d9 (patch) | |
tree | ebb3e2ad85f32cd95c767dda75d25873c384e78d /include | |
parent | de9963f0f2dfad128b26ae7bf6005f5948416a6d (diff) |
netfilter: tproxy: do not assign timewait sockets to skb->sk
Assigning a socket in timewait state to skb->sk can trigger
kernel oops, e.g. in nfnetlink_log, which does:
if (skb->sk) {
read_lock_bh(&skb->sk->sk_callback_lock);
if (skb->sk->sk_socket && skb->sk->sk_socket->file) ...
in the timewait case, accessing sk->sk_callback_lock and sk->sk_socket
is invalid.
Either all of these spots will need to add a test for sk->sk_state != TCP_TIME_WAIT,
or xt_TPROXY must not assign a timewait socket to skb->sk.
This does the latter.
If a TW socket is found, assign the tproxy nfmark, but skip the skb->sk assignment,
thus mimicking behaviour of a '-m socket .. -j MARK/ACCEPT' re-routing rule.
The 'SYN to TW socket' case is left unchanged -- we try to redirect to the
listener socket.
Cc: Balazs Scheidler <bazsi@balabit.hu>
Cc: KOVACS Krisztian <hidden@balabit.hu>
Signed-off-by: Florian Westphal <fwestphal@astaro.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/netfilter/nf_tproxy_core.h | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/include/net/netfilter/nf_tproxy_core.h b/include/net/netfilter/nf_tproxy_core.h index cd85b3bc8327..e505358d8999 100644 --- a/include/net/netfilter/nf_tproxy_core.h +++ b/include/net/netfilter/nf_tproxy_core.h | |||
@@ -201,18 +201,8 @@ nf_tproxy_get_sock_v6(struct net *net, const u8 protocol, | |||
201 | } | 201 | } |
202 | #endif | 202 | #endif |
203 | 203 | ||
204 | static inline void | ||
205 | nf_tproxy_put_sock(struct sock *sk) | ||
206 | { | ||
207 | /* TIME_WAIT inet sockets have to be handled differently */ | ||
208 | if ((sk->sk_protocol == IPPROTO_TCP) && (sk->sk_state == TCP_TIME_WAIT)) | ||
209 | inet_twsk_put(inet_twsk(sk)); | ||
210 | else | ||
211 | sock_put(sk); | ||
212 | } | ||
213 | |||
214 | /* assign a socket to the skb -- consumes sk */ | 204 | /* assign a socket to the skb -- consumes sk */ |
215 | int | 205 | void |
216 | nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk); | 206 | nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk); |
217 | 207 | ||
218 | #endif | 208 | #endif |