* [PATCH net] net/x25: inherit the listening socket's security label on accept
@ 2026-11-23 0:31 Suyuan Wang via B4 Relay
2026-11-23 0:38 ` sashiko-bot
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Suyuan Wang via B4 Relay @ 2026-11-23 0:31 UTC (permalink / raw)
To: davem, kuba, ms, edumazet, pabeni
Cc: netdev, linux-x25, linux-kernel, linux-security-module, paul
From: Suyuan Wang <stevewong@hust.edu.cn>
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.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
---
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(+)
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index f45c9ec7d2c6..802688d5ad56 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -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;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net] net/x25: inherit the listening socket's security label on accept
2026-11-23 0:31 [PATCH net] net/x25: inherit the listening socket's security label on accept Suyuan Wang via B4 Relay
@ 2026-11-23 0:38 ` sashiko-bot
2026-11-23 16:44 ` Martin Schiller
2026-11-29 15:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-23 0:38 UTC (permalink / raw)
Cc: linux-security-module
> From: Suyuan Wang <stevewong@hust.edu.cn>
>
> 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.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
> Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
> Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-x25-v1-1-4432d3892f8b@gmail.com?part=1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] net/x25: inherit the listening socket's security label on accept
2026-11-23 0:31 [PATCH net] net/x25: inherit the listening socket's security label on accept Suyuan Wang via B4 Relay
2026-11-23 0:38 ` sashiko-bot
@ 2026-11-23 16:44 ` Martin Schiller
2026-11-24 17:10 ` Paul Moore
2026-11-29 15:10 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 7+ messages in thread
From: Martin Schiller @ 2026-11-23 16:44 UTC (permalink / raw)
To: shyckless
Cc: davem, kuba, edumazet, pabeni, netdev, linux-x25, linux-kernel,
linux-security-module, paul, stevewong, kaixuan.li
On Mon, 23 Nov 2026 01:31:20 +0100, Suyuan Wang wrote:
> 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).
Thanks!
Acked-by: Martin Schiller <ms@dev.tdt.de>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] net/x25: inherit the listening socket's security label on accept
2026-11-23 16:44 ` Martin Schiller
@ 2026-11-24 17:10 ` Paul Moore
2026-11-24 17:19 ` Wong Steve
0 siblings, 1 reply; 7+ messages in thread
From: Paul Moore @ 2026-11-24 17:10 UTC (permalink / raw)
To: Martin Schiller
Cc: shyckless, davem, kuba, edumazet, pabeni, netdev, linux-x25,
linux-kernel, linux-security-module, stevewong, kaixuan.li
On Mon, Nov 23, 2026 at 11:44 AM Martin Schiller <ms@dev.tdt.de> wrote:
>
> On Mon, 23 Nov 2026 01:31:20 +0100, Suyuan Wang wrote:
> > 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).
>
> Thanks!
>
> Acked-by: Martin Schiller <ms@dev.tdt.de>
My apologies, but I'm about as X.25 ignorant as possible, so a quick
question: the x25_make_new() function is called by
x25_rx_call_request(), which as far as I can tell is on pretty
analogous to an accept() operation, is that correct?
If that's the case (x25_rx_call_request() acting similar to accept()),
cloning the listening socket's LSM data makes sense, but if it's
something else we may want to leave the new socket as-is, labeled by
the process performing the operation.
--
paul-moore.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] net/x25: inherit the listening socket's security label on accept
2026-11-24 17:10 ` Paul Moore
@ 2026-11-24 17:19 ` Wong Steve
2026-11-24 17:34 ` Paul Moore
0 siblings, 1 reply; 7+ messages in thread
From: Wong Steve @ 2026-11-24 17:19 UTC (permalink / raw)
To: Paul Moore
Cc: Martin Schiller, davem, kuba, edumazet, pabeni, netdev, linux-x25,
linux-kernel, linux-security-module, stevewong, kaixuan.li
> the x25_make_new() function is called by
> x25_rx_call_request(), which as far as I can tell is on pretty
> analogous to an accept() operation, is that correct?
Yes. x25_rx_call_request() runs in the receive path
(x25_lapb_receive_frame() -> x25_receive_data()) when a Call Request
arrives for a listening socket. It is the X.25 counterpart of TCP
creating the child socket for an incoming connection:
- x25_find_listener() finds the listening socket,
- x25_make_new() creates the new socket and copies the listener's
settings,
- the new socket is queued on the listener's receive queue, and
- x25_accept() later takes it off the queue and grafts it onto the
socket that accept() returns.
This runs when the packet is received, not on behalf of the process
that later calls accept(), so there is no process to take a label
from. Without the clone, the new sock keeps the default state from
sk_alloc(), which is unlabeled for SELinux. For TCP the same step goes
through sk_clone_lock() and sock_copy(), which calls
security_sk_clone().
Thanks,
Suyuan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] net/x25: inherit the listening socket's security label on accept
2026-11-24 17:19 ` Wong Steve
@ 2026-11-24 17:34 ` Paul Moore
0 siblings, 0 replies; 7+ messages in thread
From: Paul Moore @ 2026-11-24 17:34 UTC (permalink / raw)
To: Wong Steve
Cc: Martin Schiller, davem, kuba, edumazet, pabeni, netdev, linux-x25,
linux-kernel, linux-security-module, stevewong, kaixuan.li
On Tue, Nov 24, 2026 at 12:19 PM Wong Steve <shyckless@gmail.com> wrote:
> > the x25_make_new() function is called by
> > x25_rx_call_request(), which as far as I can tell is on pretty
> > analogous to an accept() operation, is that correct?
>
> Yes. x25_rx_call_request() runs in the receive path
> (x25_lapb_receive_frame() -> x25_receive_data()) when a Call Request
> arrives for a listening socket. It is the X.25 counterpart of TCP
> creating the child socket for an incoming connection:
>
> - x25_find_listener() finds the listening socket,
> - x25_make_new() creates the new socket and copies the listener's
> settings,
> - the new socket is queued on the listener's receive queue, and
> - x25_accept() later takes it off the queue and grafts it onto the
> socket that accept() returns.
Great, thanks.
Reviewed-by: Paul Moore <paul@paul-moore.com>
--
paul-moore.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] net/x25: inherit the listening socket's security label on accept
2026-11-23 0:31 [PATCH net] net/x25: inherit the listening socket's security label on accept Suyuan Wang via B4 Relay
2026-11-23 0:38 ` sashiko-bot
2026-11-23 16:44 ` Martin Schiller
@ 2026-11-29 15:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-29 15:10 UTC (permalink / raw)
To: Wong Steve
Cc: davem, kuba, ms, edumazet, pabeni, netdev, linux-x25,
linux-kernel, linux-security-module, paul
Hello:
This patch was applied to netdev/net.git (main)
by Willem de Bruijn <willemb@google.com>:
On Mon, 23 Nov 2026 00:31:20 +0000 you wrote:
> From: Suyuan Wang <stevewong@hust.edu.cn>
>
> 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.
>
> [...]
Here is the summary with links:
- [net] net/x25: inherit the listening socket's security label on accept
https://git.kernel.org/netdev/net/c/c972b41fe1a5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-29 15:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 0:31 [PATCH net] net/x25: inherit the listening socket's security label on accept Suyuan Wang via B4 Relay
2026-11-23 0:38 ` sashiko-bot
2026-11-23 16:44 ` Martin Schiller
2026-11-24 17:10 ` Paul Moore
2026-11-24 17:19 ` Wong Steve
2026-11-24 17:34 ` Paul Moore
2026-11-29 15:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox