Skip to content

Commit d77b6ff

Browse files
stanislavfortaislesimonwunderlich
authored andcommitted
batman-adv: fix OOB read/write in network-coding decode
batadv_nc_skb_decode_packet() trusts coded_len and checks only against skb->len. XOR starts at sizeof(struct batadv_unicast_packet), reducing payload headroom, and the source skb length is not verified, allowing an out-of-bounds read and a small out-of-bounds write. Validate that coded_len fits within the payload area of both destination and source sk_buffs before XORing. Fixes: 2df5278 ("batman-adv: network coding - receive coded packets and decode them") Cc: [email protected] Reported-by: Stanislav Fort <[email protected]> Signed-off-by: Stanislav Fort <[email protected]> Signed-off-by: Sven Eckelmann <[email protected]> Signed-off-by: Simon Wunderlich <[email protected]>
1 parent 6439a0e commit d77b6ff

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

net/batman-adv/network-coding.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,12 @@ batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb,
16871687

16881688
coding_len = ntohs(coded_packet_tmp.coded_len);
16891689

1690-
if (coding_len > skb->len)
1690+
/* ensure dst buffer is large enough (payload only) */
1691+
if (coding_len + h_size > skb->len)
1692+
return NULL;
1693+
1694+
/* ensure src buffer is large enough (payload only) */
1695+
if (coding_len + h_size > nc_packet->skb->len)
16911696
return NULL;
16921697

16931698
/* Here the magic is reversed:

0 commit comments

Comments
 (0)