Skip to content

Commit fa2df45

Browse files
q2venPaolo Abeni
authored andcommitted
dccp: Call security_inet_conn_request() after setting IPv4 addresses.
Initially, commit 4237c75 ("[MLSXFRM]: Auto-labeling of child sockets") introduced security_inet_conn_request() in some functions where reqsk is allocated. The hook is added just after the allocation, so reqsk's IPv4 remote address was not initialised then. However, SELinux/Smack started to read it in netlbl_req_setattr() after the cited commits. This bug was partially fixed by commit 284904a ("lsm: Relocate the IPv4 security_inet_conn_request() hooks"). This patch fixes the last bug in DCCPv4. Fixes: 389fb80 ("netlabel: Label incoming TCP connections correctly in SELinux") Fixes: 07feee8 ("netlabel: Cleanup the Smack/NetLabel code to fix incoming TCP connections") Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Acked-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent a1602d7 commit fa2df45

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/dccp/ipv4.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,16 +629,16 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
629629
if (dccp_parse_options(sk, dreq, skb))
630630
goto drop_and_free;
631631

632-
if (security_inet_conn_request(sk, skb, req))
633-
goto drop_and_free;
634-
635632
ireq = inet_rsk(req);
636633
sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
637634
sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
638635
ireq->ir_mark = inet_request_mark(sk, skb);
639636
ireq->ireq_family = AF_INET;
640637
ireq->ir_iif = READ_ONCE(sk->sk_bound_dev_if);
641638

639+
if (security_inet_conn_request(sk, skb, req))
640+
goto drop_and_free;
641+
642642
/*
643643
* Step 3: Process LISTEN state
644644
*

0 commit comments

Comments
 (0)