You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
net: add skb_to_full_sk() helper and use it in selinux_netlbl_skbuff_setsid()
Generalize selinux_skb_sk() added in commit212cd08953("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:ca6fb06518("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>
This commit is contained in:
committed by
David S. Miller
parent
fb9a10d9d8
commit
54abc686c2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user