* [PATCH net] mac802154: remove redundant security_enabled assignment
@ 2026-11-16 6:52 Petr Vaganov
2026-11-17 11:06 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Petr Vaganov @ 2026-11-16 6:52 UTC (permalink / raw)
To: Alexander Aring, Stefan Schmidt, Miquel Raynal, linux-wpan
Cc: Petr Vaganov, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Phoebe Buckheister, netdev,
linux-kernel, lvc-project, stable
During fuzz testing, the following issue was discovered:
BUG: KMSAN: uninit-value in ieee802154_hdr_push_sechdr net/ieee802154/header_ops.c:54 [inline]
BUG: KMSAN: uninit-value in ieee802154_hdr_push+0xa62/0xb20 net/ieee802154/header_ops.c:108
ieee802154_hdr_push_sechdr net/ieee802154/header_ops.c:54 [inline]
ieee802154_hdr_push+0xa62/0xb20 net/ieee802154/header_ops.c:108
ieee802154_header_create+0xa83/0xd20 net/mac802154/iface.c:396
wpan_dev_hard_header include/net/cfg802154.h:525 [inline]
dgram_sendmsg+0xc6d/0x15d0 net/ieee802154/socket.c:677
ieee802154_sock_sendmsg+0x8f/0xd0 net/ieee802154/socket.c:96
sock_sendmsg_nosec net/socket.c:711 [inline]
__sock_sendmsg+0x2f3/0x360 net/socket.c:726
____sys_sendmsg+0x960/0xc30 net/socket.c:2581
___sys_sendmsg+0x285/0x3e0 net/socket.c:2635
__sys_sendmmsg+0x33c/0x950 net/socket.c:2724
__do_sys_sendmmsg net/socket.c:2751 [inline]
__se_sys_sendmmsg net/socket.c:2748 [inline]
__x64_sys_sendmmsg+0xc6/0x150 net/socket.c:2748
x64_sys_call+0x12a8/0x3cf0 arch/x86/include/generated/asm/syscalls_64.h:308
do_syscall_x64 arch/x86/entry/common.c:47 [inline]
do_syscall_64+0xd9/0x1c0 arch/x86/entry/common.c:78
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was stored to memory at:
ieee802154_hdr_push_sechdr net/ieee802154/header_ops.c:51 [inline]
ieee802154_hdr_push+0xa5b/0xb20 net/ieee802154/header_ops.c:108
ieee802154_header_create+0xa83/0xd20 net/mac802154/iface.c:396
wpan_dev_hard_header include/net/cfg802154.h:525 [inline]
dgram_sendmsg+0xc6d/0x15d0 net/ieee802154/socket.c:677
ieee802154_sock_sendmsg+0x8f/0xd0 net/ieee802154/socket.c:96
sock_sendmsg_nosec net/socket.c:711 [inline]
__sock_sendmsg+0x2f3/0x360 net/socket.c:726
____sys_sendmsg+0x960/0xc30 net/socket.c:2581
___sys_sendmsg+0x285/0x3e0 net/socket.c:2635
__sys_sendmmsg+0x33c/0x950 net/socket.c:2724
__do_sys_sendmmsg net/socket.c:2751 [inline]
__se_sys_sendmmsg net/socket.c:2748 [inline]
__x64_sys_sendmmsg+0xc6/0x150 net/socket.c:2748
x64_sys_call+0x12a8/0x3cf0 arch/x86/include/generated/asm/syscalls_64.h:308
do_syscall_x64 arch/x86/entry/common.c:47 [inline]
do_syscall_64+0xd9/0x1c0 arch/x86/entry/common.c:78
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Commit f30be4d53cad ("mac802154: integrate llsec with wpan devices")
introduced mac802154_set_header_security() as the sole function
responsible for enabling frame-level security: it sets both
hdr->fc.security_enabled = 1 and initializes hdr->sec together,
maintaining the invariant that security_enabled = 1 implies hdr->sec
is initialized.
However, ieee802154_header_create() was left with a pre-existing
assignment:
hdr.fc.security_enabled = cb->secen;
This assignment can set security_enabled = 1 (from a stale cb->secen)
even when mac802154_set_header_security() returns 0 without initializing
hdr.sec, violating that invariant. ieee802154_hdr_push_sechdr() then
reads uninitialized hdr.sec fields.
The stale value in cb->secen arises from a specific setsockopt()
sequence: calling WPAN_SECURITY_ON (secen_override=1, secen=1) and
then WPAN_SECURITY_DEFAULT (secen_override=0, secen unchanged at 1).
This undocumented combination likely explains why the bug was rarely
triggered.
Remove the redundant assignment; mac802154_set_header_security() is the
only correct place to set security_enabled.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
Closes: https://syzkaller.appspot.com/bug?extid=60a66d44892b66b56545
Closes: https://syzkaller.appspot.com/bug?id=23f21e76e9d2d1ed587cb5e71515260d6d025b63
Fixes: f30be4d53cad ("mac802154: integrate llsec with wpan devices")
Cc: stable@vger.kernel.org
Signed-off-by: Petr Vaganov <petrvaganoff@gmail.com>
---
net/mac802154/iface.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
index f437b8daa00d..7b7332805ecc 100644
--- a/net/mac802154/iface.c
+++ b/net/mac802154/iface.c
@@ -368,7 +368,6 @@ static int ieee802154_header_create(struct sk_buff *skb,
memset(&hdr.fc, 0, sizeof(hdr.fc));
hdr.fc.type = cb->type;
- hdr.fc.security_enabled = cb->secen;
hdr.fc.ack_request = cb->ackreq;
hdr.seq = atomic_inc_return(&dev->ieee802154_ptr->dsn) & 0xFF;
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] mac802154: remove redundant security_enabled assignment
2026-11-16 6:52 [PATCH net] mac802154: remove redundant security_enabled assignment Petr Vaganov
@ 2026-11-17 11:06 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2026-11-17 11:06 UTC (permalink / raw)
To: Petr Vaganov
Cc: Alexander Aring, Stefan Schmidt, linux-wpan, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Phoebe Buckheister, netdev, linux-kernel, lvc-project, stable
On 16/11/2026 at 13:52:34 +07, Petr Vaganov <petrvaganoff@gmail.com> wrote:
> During fuzz testing, the following issue was discovered:
>
> BUG: KMSAN: uninit-value in ieee802154_hdr_push_sechdr net/ieee802154/header_ops.c:54 [inline]
> BUG: KMSAN: uninit-value in ieee802154_hdr_push+0xa62/0xb20 net/ieee802154/header_ops.c:108
> ieee802154_hdr_push_sechdr net/ieee802154/header_ops.c:54 [inline]
> ieee802154_hdr_push+0xa62/0xb20 net/ieee802154/header_ops.c:108
> ieee802154_header_create+0xa83/0xd20 net/mac802154/iface.c:396
> wpan_dev_hard_header include/net/cfg802154.h:525 [inline]
> dgram_sendmsg+0xc6d/0x15d0 net/ieee802154/socket.c:677
> ieee802154_sock_sendmsg+0x8f/0xd0 net/ieee802154/socket.c:96
> sock_sendmsg_nosec net/socket.c:711 [inline]
> __sock_sendmsg+0x2f3/0x360 net/socket.c:726
> ____sys_sendmsg+0x960/0xc30 net/socket.c:2581
> ___sys_sendmsg+0x285/0x3e0 net/socket.c:2635
> __sys_sendmmsg+0x33c/0x950 net/socket.c:2724
> __do_sys_sendmmsg net/socket.c:2751 [inline]
> __se_sys_sendmmsg net/socket.c:2748 [inline]
> __x64_sys_sendmmsg+0xc6/0x150 net/socket.c:2748
> x64_sys_call+0x12a8/0x3cf0 arch/x86/include/generated/asm/syscalls_64.h:308
> do_syscall_x64 arch/x86/entry/common.c:47 [inline]
> do_syscall_64+0xd9/0x1c0 arch/x86/entry/common.c:78
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> Uninit was stored to memory at:
> ieee802154_hdr_push_sechdr net/ieee802154/header_ops.c:51 [inline]
> ieee802154_hdr_push+0xa5b/0xb20 net/ieee802154/header_ops.c:108
> ieee802154_header_create+0xa83/0xd20 net/mac802154/iface.c:396
> wpan_dev_hard_header include/net/cfg802154.h:525 [inline]
> dgram_sendmsg+0xc6d/0x15d0 net/ieee802154/socket.c:677
> ieee802154_sock_sendmsg+0x8f/0xd0 net/ieee802154/socket.c:96
> sock_sendmsg_nosec net/socket.c:711 [inline]
> __sock_sendmsg+0x2f3/0x360 net/socket.c:726
> ____sys_sendmsg+0x960/0xc30 net/socket.c:2581
> ___sys_sendmsg+0x285/0x3e0 net/socket.c:2635
> __sys_sendmmsg+0x33c/0x950 net/socket.c:2724
> __do_sys_sendmmsg net/socket.c:2751 [inline]
> __se_sys_sendmmsg net/socket.c:2748 [inline]
> __x64_sys_sendmmsg+0xc6/0x150 net/socket.c:2748
> x64_sys_call+0x12a8/0x3cf0 arch/x86/include/generated/asm/syscalls_64.h:308
> do_syscall_x64 arch/x86/entry/common.c:47 [inline]
> do_syscall_64+0xd9/0x1c0 arch/x86/entry/common.c:78
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> Commit f30be4d53cad ("mac802154: integrate llsec with wpan devices")
> introduced mac802154_set_header_security() as the sole function
> responsible for enabling frame-level security: it sets both
> hdr->fc.security_enabled = 1 and initializes hdr->sec together,
> maintaining the invariant that security_enabled = 1 implies hdr->sec
> is initialized.
>
> However, ieee802154_header_create() was left with a pre-existing
> assignment:
>
> hdr.fc.security_enabled = cb->secen;
>
> This assignment can set security_enabled = 1 (from a stale cb->secen)
> even when mac802154_set_header_security() returns 0 without initializing
> hdr.sec, violating that invariant. ieee802154_hdr_push_sechdr() then
> reads uninitialized hdr.sec fields.
>
> The stale value in cb->secen arises from a specific setsockopt()
> sequence: calling WPAN_SECURITY_ON (secen_override=1, secen=1) and
> then WPAN_SECURITY_DEFAULT (secen_override=0, secen unchanged at 1).
> This undocumented combination likely explains why the bug was rarely
> triggered.
>
> Remove the redundant assignment; mac802154_set_header_security() is the
> only correct place to set security_enabled.
>
> Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
>
> Closes: https://syzkaller.appspot.com/bug?extid=60a66d44892b66b56545
> Closes: https://syzkaller.appspot.com/bug?id=23f21e76e9d2d1ed587cb5e71515260d6d025b63
> Fixes: f30be4d53cad ("mac802154: integrate llsec with wpan devices")
> Cc: stable@vger.kernel.org
> Signed-off-by: Petr Vaganov <petrvaganoff@gmail.com>
> ---
> net/mac802154/iface.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
> index f437b8daa00d..7b7332805ecc 100644
> --- a/net/mac802154/iface.c
> +++ b/net/mac802154/iface.c
> @@ -368,7 +368,6 @@ static int ieee802154_header_create(struct sk_buff *skb,
>
> memset(&hdr.fc, 0, sizeof(hdr.fc));
> hdr.fc.type = cb->type;
> - hdr.fc.security_enabled = cb->secen;
> hdr.fc.ack_request = cb->ackreq;
> hdr.seq = atomic_inc_return(&dev->ieee802154_ptr->dsn) & 0xFF;
There has been a similar patch in 2023 but it was never updated by the
author. Fixes tag is better here, it should be taken.
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Thanks,
Miquèl
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-17 11:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 6:52 [PATCH net] mac802154: remove redundant security_enabled assignment Petr Vaganov
2026-11-17 11:06 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox