summaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2015-11-08 10:54:07 -0800
committerDavid S. Miller <davem@davemloft.net>2015-11-08 20:56:38 -0500
commit54abc686c2d111e98228943a7e1e51cc256e35d9 (patch)
tree5ce71817a67798bdd4a669a63b110d83952c2feb /include/net
parentfb9a10d9d8552acf6f9dee2ecb2d047777821d8b (diff)
downloadlinux-stable-54abc686c2d111e98228943a7e1e51cc256e35d9.tar.gz
linux-stable-54abc686c2d111e98228943a7e1e51cc256e35d9.tar.bz2
linux-stable-54abc686c2d111e98228943a7e1e51cc256e35d9.zip
net: add skb_to_full_sk() helper and use it in selinux_netlbl_skbuff_setsid()
Generalize selinux_skb_sk() added in commit 212cd0895330 ("selinux: fix random read in selinux_ip_postroute_compat()") so that we can use it other contexts. Use it right away in selinux_netlbl_skbuff_setsid() Fixes: ca6fb0651883 ("tcp: attach SYNACK messages to request sockets instead of listener") Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/inet_sock.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index f5bf7310e334..2134e6d815bc 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -210,6 +210,18 @@ struct inet_sock {
#define IP_CMSG_ORIGDSTADDR BIT(6)
#define IP_CMSG_CHECKSUM BIT(7)
+/* SYNACK messages might be attached to request sockets.
+ * Some places want to reach the listener in this case.
+ */
+static inline struct sock *skb_to_full_sk(const struct sk_buff *skb)
+{
+ struct sock *sk = skb->sk;
+
+ if (sk && sk->sk_state == TCP_NEW_SYN_RECV)
+ sk = inet_reqsk(sk)->rsk_listener;
+ return sk;
+}
+
static inline struct inet_sock *inet_sk(const struct sock *sk)
{
return (struct inet_sock *)sk;