Skip to content

Commit

Permalink
Bluetooth: bnep: Fix out-of-bound access
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vudentz committed Mar 6, 2024
1 parent 79f4127 commit 0f0639b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/bluetooth/bnep/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0f0639b

Please sign in to comment.