Skip to content

Commit a27ef29

Browse files
KatharaaNipaLocal
authored andcommitted
mac802154: fix uninitialized security header fields
KMSAN reported an uninitialized-value access in ieee802154_hdr_push_sechdr(). This happened because mac802154_set_header_security() allowed frames with cb->secen=1 but LLSEC disabled when secen_override=0, leaving parts of the security header uninitialized. Fix the validation so security-enabled frames are rejected whenever LLSEC is disabled, regardless of secen_override. Also clear the full header struct in the header creation functions to avoid partial initialization. Reported-by: syzbot+60a66d44892b66b56545@syzkaller.appspotmail.com Tested-by: syzbot+60a66d44892b66b56545@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=60a66d44892b66b56545 Signed-off-by: Kathara Sasikumar <katharasasikumar007@gmail.com> Signed-off-by: NipaLocal <nipa@local>
1 parent e07c47c commit a27ef29

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

net/mac802154/iface.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,14 @@ static int mac802154_set_header_security(struct ieee802154_sub_if_data *sdata,
328328

329329
mac802154_llsec_get_params(&sdata->sec, &params);
330330

331-
if (!params.enabled && cb->secen_override && cb->secen)
332-
return -EINVAL;
331+
if (!cb->secen_override) {
332+
if (!params.enabled)
333+
return 0;
334+
} else {
335+
if (cb->secen && !params.enabled)
336+
return -EINVAL;
337+
}
338+
333339
if (!params.enabled ||
334340
(cb->secen_override && !cb->secen) ||
335341
!params.out_level)
@@ -366,7 +372,7 @@ static int ieee802154_header_create(struct sk_buff *skb,
366372
if (!daddr)
367373
return -EINVAL;
368374

369-
memset(&hdr.fc, 0, sizeof(hdr.fc));
375+
memset(&hdr, 0, sizeof(hdr));
370376
hdr.fc.type = cb->type;
371377
hdr.fc.security_enabled = cb->secen;
372378
hdr.fc.ack_request = cb->ackreq;
@@ -432,7 +438,7 @@ static int mac802154_header_create(struct sk_buff *skb,
432438
if (!daddr)
433439
return -EINVAL;
434440

435-
memset(&hdr.fc, 0, sizeof(hdr.fc));
441+
memset(&hdr, 0, sizeof(hdr));
436442
hdr.fc.type = IEEE802154_FC_TYPE_DATA;
437443
hdr.fc.ack_request = wpan_dev->ackreq;
438444
hdr.seq = atomic_inc_return(&dev->ieee802154_ptr->dsn) & 0xFF;

0 commit comments

Comments
 (0)