aboutsummaryrefslogtreecommitdiff
path: root/net/netfilter
diff options
context:
space:
mode:
authorJP Abgrall <jpa@google.com>2013-02-20 16:38:34 -0800
committerRuchi Kandoi <kandoiruchi@google.com>2015-02-03 18:34:59 -0800
commit816a0d9b8a195b155f95124dc9e9a9754a971940 (patch)
tree996186b5bcb0e04889b3ee06d96dc12e4a28f34a /net/netfilter
parent1c9fcf4b41d5df043f0050ff707cf726b47725b2 (diff)
netfilter: xt_qtaguid: fix bad tcp_time_wait sock handling
Since (41063e9 ipv4: Early TCP socket demux), skb's can have an sk which is not a struct sock but the smaller struct inet_timewait_sock without an sk->sk_socket. Now we bypass sk_state == TCP_TIME_WAIT Signed-off-by: JP Abgrall <jpa@google.com>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/xt_qtaguid.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/net/netfilter/xt_qtaguid.c b/net/netfilter/xt_qtaguid.c
index 4ec6d23876c5..5e07c3375b56 100644
--- a/net/netfilter/xt_qtaguid.c
+++ b/net/netfilter/xt_qtaguid.c
@@ -1694,14 +1694,13 @@ static struct sock *qtaguid_find_sk(const struct sk_buff *skb,
return NULL;
}
- /*
- * Seems to be issues on the file ptr for TCP_TIME_WAIT SKs.
- * http://kerneltrap.org/mailarchive/linux-netdev/2010/10/21/6287959
- * Not fixed in 3.0-r3 :(
- */
if (sk) {
MT_DEBUG("qtaguid: %p->sk_proto=%u "
"->sk_state=%d\n", sk, sk->sk_protocol, sk->sk_state);
+ /*
+ * When in TCP_TIME_WAIT the sk is not a "struct sock" but
+ * "struct inet_timewait_sock" which is missing fields.
+ */
if (sk->sk_state == TCP_TIME_WAIT) {
xt_socket_put_sk(sk);
sk = NULL;
@@ -1785,6 +1784,13 @@ static bool qtaguid_mt(const struct sk_buff *skb, struct xt_action_param *par)
}
sk = skb->sk;
+ /*
+ * When in TCP_TIME_WAIT the sk is not a "struct sock" but
+ * "struct inet_timewait_sock" which is missing fields.
+ * So we ignore it.
+ */
+ if (sk && sk->sk_state == TCP_TIME_WAIT)
+ sk = NULL;
if (sk == NULL) {
/*
* A missing sk->sk_socket happens when packets are in-flight