From: Petr Vaganov <petrvaganoff@gmail.com>
To: alex.aring@gmail.com, stefan@datenfreihafen.org,
miquel.raynal@bootlin.com, linux-wpan@vger.kernel.org
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org,
phoebe.buckheister@itwm.fraunhofer.de, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Petr Vaganov <petrvaganoff@gmail.com>
Subject: [PATCH v2 net] mac802154: fix uninit-value in ieee802154_header_create()
Date: Fri, 20 Nov 2026 15:45:37 +0700 [thread overview]
Message-ID: <20261120084537.31991-1-petrvaganoff@gmail.com> (raw)
In-Reply-To: <20261116065235.27348-1-petrvaganoff@gmail.com>
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:310
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
Both ieee802154_header_create() and mac802154_header_create() declare
struct ieee802154_hdr hdr on the stack and clear only hdr.fc via
memset. This leaves hdr.sec uninitialized.
There are two ways uninitialized hdr.sec fields can be read:
1. ieee802154_header_create() had a pre-existing assignment:
hdr.fc.security_enabled = cb->secen;
This could set security_enabled = 1 from a stale cb->secen (e.g.,
after WPAN_SECURITY_ON followed by WPAN_SECURITY_DEFAULT), even when
mac802154_set_header_security() returns without initializing hdr.sec.
ieee802154_hdr_push_sechdr() would then read uninitialized hdr.sec.
2. mac802154_set_header_security() never writes sec.frame_counter.
ieee802154_hdr_push_sechdr() copies it from the stack into the skb
before mac802154_llsec_encrypt() sets the real value. If encryption
fails, or via AF_PACKET taps in dev_queue_xmit_nit(), the
uninitialized bytes are exposed to userspace.
Fix both issues by replacing memset(&hdr.fc, ...) with
memset(&hdr, ...) in both functions, which zeros hdr.sec entirely
before mac802154_set_header_security() is called. The stale
hdr.fc.security_enabled assignment is also removed as it is now
superseded by the full zero-initialization.
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>
---
Changes in v2:
- Replace memset(&hdr.fc, ...) with memset(&hdr, ...) in both
ieee802154_header_create() and mac802154_header_create() to also
zero hdr.sec, closing the pre-existing uninitialized sec.frame_counter
read on the normal TX path (noted by Sashiko AI review).
- Rename subject to reflect this is a bug fix, not a cleanup.
net/mac802154/iface.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
index f437b8daa00d..36bdd7558810 100644
--- a/net/mac802154/iface.c
+++ b/net/mac802154/iface.c
@@ -366,9 +366,8 @@ static int ieee802154_header_create(struct sk_buff *skb,
if (!daddr)
return -EINVAL;
- memset(&hdr.fc, 0, sizeof(hdr.fc));
+ memset(&hdr, 0, sizeof(hdr));
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;
@@ -433,7 +432,7 @@ static int mac802154_header_create(struct sk_buff *skb,
if (!daddr)
return -EINVAL;
- memset(&hdr.fc, 0, sizeof(hdr.fc));
+ memset(&hdr, 0, sizeof(hdr));
hdr.fc.type = IEEE802154_FC_TYPE_DATA;
hdr.fc.ack_request = wpan_dev->ackreq;
hdr.seq = atomic_inc_return(&dev->ieee802154_ptr->dsn) & 0xFF;
--
2.55.0
next prev parent reply other threads:[~2026-11-20 8:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 6:52 [PATCH net] mac802154: remove redundant security_enabled assignment Petr Vaganov
2026-11-17 11:06 ` Miquel Raynal
2026-11-18 2:04 ` netdev-bot+sashiko
2026-11-20 8:45 ` Petr Vaganov [this message]
2026-11-20 13:41 ` [PATCH v2 net] mac802154: fix uninit-value in ieee802154_header_create() Miquel Raynal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120084537.31991-1-petrvaganoff@gmail.com \
--to=petrvaganoff@gmail.com \
--cc=alex.aring@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=phoebe.buckheister@itwm.fraunhofer.de \
--cc=stable@vger.kernel.org \
--cc=stefan@datenfreihafen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.