Skip to content

Commit

Permalink
dccp: Call security_inet_conn_request() after setting IPv4 addresses.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
q2ven authored and Paolo Abeni committed Nov 2, 2023
1 parent a1602d7 commit fa2df45
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/dccp/ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,16 +629,16 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
if (dccp_parse_options(sk, dreq, skb))
goto drop_and_free;

if (security_inet_conn_request(sk, skb, req))
goto drop_and_free;

ireq = inet_rsk(req);
sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
ireq->ir_mark = inet_request_mark(sk, skb);
ireq->ireq_family = AF_INET;
ireq->ir_iif = READ_ONCE(sk->sk_bound_dev_if);

if (security_inet_conn_request(sk, skb, req))
goto drop_and_free;

/*
* Step 3: Process LISTEN state
*
Expand Down

0 comments on commit fa2df45

Please sign in to comment.