net/x25: inherit the listening socket's security label on accept
Subsystems (4)
PATCH 1/1 net/x25: inherit the listening socket's security label on accept
From: Suyuan Wang <[email protected]>
x25_make_new() creates the socket that accept() returns by copying fields from the listening socket, but it never clones the listening socket's LSM security state -- there is no security_sk_clone(osk, sk). The accepted socket therefore keeps the security state that was newly allocated for it in x25_alloc_socket(), instead of inheriting the listening socket's security state.
Other accept paths (bluetooth, tipc, vsock, iucv) call security_sk_clone() for this. Do the same for X.25.
Found with a static analysis tool and checked by hand.
---
Compile tested on x86_64 (W=1, no new warnings). I don't have X.25 hardware; the fix is by inspection.
--- net/x25/af_x25.c | 1 + 1 file changed, 1 insertion(+)
net/x25/af_x25.c +1 -0
@@ -598,6 +598,7 @@ static struct sock *x25_make_new(struct sock *osk) sk->sk_state =TCP_ESTABLISHED ; sk->sk_backlog_rcv = osk->sk_backlog_rcv;sock_copy_flags (sk, osk); +security_sk_clone (osk, sk); ox25 =x25_sk (osk); x25->t21 = ox25->t21;
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 12 lines
From: Suyuan Wang <[email protected]>
x25_make_new()creates the socket thataccept()returns by copying fields from the listening socket, but it never clones the listening socket's LSM security state -- there is nosecurity_sk_clone(osk, sk). The accepted socket therefore keeps the security state that was newly allocated for it inx25_alloc_socket(), instead of inheriting the listening socket's security state.Other accept paths (bluetooth, tipc, vsock, iucv) call
security_sk_clone()for this. Do the same for X.25.
Quoted 7 lines
Found with a static analysis tool and checked by hand.
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Co-developed-by Kaixuan Li <[email protected]>Signed-off-by Kaixuan Li <[email protected]>Signed-off-by Suyuan Wang <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 3 lines · Suyuan Wang
x25_make_new()creates the socket thataccept()returns by copying fields from the listening socket, but it never clones the listening socket's LSM security state -- there is nosecurity_sk_clone(osk, sk).
Thanks!