Re: [PATCH net 1/2] nfc: llcp: Clone LSM attributes to newly created child sockets
From: Simon Horman
Date: Wed Nov 18 2026 - 13:16:21 EST
On Thu, Nov 12, 2026 at 10:04:48AM +0000, Suyuan Wang via B4 Relay wrote:
> From: Suyuan Wang <stevewong@xxxxxxxxxxx>
>
> nfc_llcp_recv_connect() creates the child socket for an incoming
> CONNECT and queues it for accept(), but never calls security_sk_clone():
>
> new_sk = nfc_llcp_sock_alloc(NULL, parent->sk_type, GFP_ATOMIC, 0);
> ...
> new_sock = nfc_llcp_sock(new_sk);
>
> So the accepted socket doesn't inherit the LSM state of the listening
> socket. With SELinux, its sock keeps the unlabeled SID. The
> sock_has_perm() checks on it (sendmsg, recvmsg and so on) still run,
> but against that SID instead of the server's. Depending on the policy,
> this can deny a confined server on its own accepted sockets, or allow
> something the server's own label wouldn't.
>
> Call security_sk_clone() right after the child is allocated, before it
> is set up and queued for accept(). Bluetooth, iucv and vsock fixed the
> same problem the same way, in commit 6230c9b4f895 ("bluetooth: Properly
> clone LSM attributes to newly created child connections"),
> commit 02f06918156b ("iucv: properly clone LSM attributes to newly
> created child sockets") and commit 1f935e8e72ec ("selinux: vsock: Set
> SID for socket returned by accept()").
>
> Found with a static analysis tool and checked by hand.
>
> Fixes: d646960f7986 ("NFC: Initial LLCP support")
> Cc: stable@xxxxxxxxxxxxxxx
> Co-developed-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
> Signed-off-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
> Signed-off-by: Suyuan Wang <stevewong@xxxxxxxxxxx>
> ---
> Compile tested only, I haven't tried it with an SELinux policy and a
> real LLCP peer.
> ---
Reviewed-by: Simon Horman <horms@xxxxxxxxxx>