Skip to content

Commit 5bbf0cd

Browse files
peaktwilightgregkh
authored andcommitted
mac802154: llsec: reject frames shorter than the authentication tag
commit fd3a3f2 upstream. llsec_do_decrypt_auth() computes the associated-data length for the AEAD request as assoclen += datalen - authlen; where datalen is the number of bytes after the MAC header and authlen (4, 8 or 16) is the length of the authentication tag. Nothing verifies that the frame actually carries at least authlen payload bytes. A secured frame whose payload is shorter than the tag makes datalen - authlen negative; assoclen is then passed to aead_request_set_ad() as an unsigned value close to 4 GiB, so crypto_aead_decrypt() walks far off the end of the scatterlist that only spans the real frame. The frame is fully attacker-controlled and reaches this path from any IEEE 802.15.4 peer in radio range. Reject frames whose payload is shorter than the authentication tag before the subtraction. Dynamically reproduced on a KASAN kernel as a general-protection-fault in the AEAD scatterwalk, and the fix confirmed. Fixes: 4c14a2f ("mac802154: add llsec decryption method") Cc: stable@vger.kernel.org Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Doruk Tan Ozturk <doruk@0sec.ai> Link: https://patch.msgid.link/20260716193423.32498-1-doruk@0sec.ai Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bd7110f commit 5bbf0cd

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

net/mac802154/llsec.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,11 @@ llsec_do_decrypt_auth(struct sk_buff *skb, const struct mac802154_llsec *sec,
891891
data = skb_mac_header(skb) + skb->mac_len;
892892
datalen = skb_tail_pointer(skb) - data;
893893

894+
if (datalen < authlen) {
895+
kfree_sensitive(req);
896+
return -EBADMSG;
897+
}
898+
894899
sg_init_one(&sg, skb_mac_header(skb), assoclen + datalen);
895900

896901
if (!(hdr->sec.level & IEEE802154_SCF_SECLEVEL_ENC)) {

0 commit comments

Comments
 (0)