]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: bnep: Fix out-of-bound access
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 28 Feb 2024 17:11:08 +0000 (12:11 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Sep 2024 11:17:37 +0000 (13:17 +0200)
[ Upstream commit 0f0639b4d6f649338ce29c62da3ec0787fa08cd1 ]

This fixes attempting to access past ethhdr.h_source, although it seems
intentional to copy also the contents of h_proto this triggers
out-of-bound access problems with the likes of static analyzer, so this
instead just copy ETH_ALEN and then proceed to use put_unaligned to copy
h_proto separetely.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bluetooth/bnep/core.c

index 09b6d825124eeaeba5f1e33f16e02772e5219559..f749904272961fac915ac7cd447719b076f743b2 100644 (file)
@@ -385,7 +385,8 @@ static int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
 
        case BNEP_COMPRESSED_DST_ONLY:
                __skb_put_data(nskb, skb_mac_header(skb), ETH_ALEN);
-               __skb_put_data(nskb, s->eh.h_source, ETH_ALEN + 2);
+               __skb_put_data(nskb, s->eh.h_source, ETH_ALEN);
+               put_unaligned(s->eh.h_proto, (__be16 *)__skb_put(nskb, 2));
                break;
 
        case BNEP_GENERAL: