summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2026-06-26 18:11:41 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-04 13:43:30 +0200
commit39007d07000dbcb7b2c8b0bfcc7e0ffd21dd70ec (patch)
tree8b66c57244cf7420c237e4b5086925fcf72a9f3c
parentf54d85feecc538ae114ca60d589ff6c676d424e5 (diff)
downloadlinux-stable-39007d07000dbcb7b2c8b0bfcc7e0ffd21dd70ec.tar.gz
linux-stable-39007d07000dbcb7b2c8b0bfcc7e0ffd21dd70ec.zip
batman-adv: ensure bcast is writable before modifying TTL
commit 4cd6d3a4b96a8576f1fed8f9f9f17c2dc2978e0c upstream. Before batman-adv is allowed to write to an skb, it either has to have its own copy of the skb or used skb_cow() to ensure that the data part is not shared. The old implementation used a shared queue and created copies before attempting to write to it. But with the new implementation, the broadcast packet is already modified when it gets received. Potentially writing to shared buffers in this process. Adding a skb_cow() right before this operation avoids this and can at the same time prepare it for the modifications required to rebroadcast the packet. Cc: stable@kernel.org Fixes: 3f69339068f9 ("batman-adv: bcast: queue per interface, if needed") Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--net/batman-adv/routing.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index f1061985149f..32a40c1c115c 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -1198,6 +1198,12 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
if (batadv_is_my_mac(bat_priv, bcast_packet->orig))
goto free_skb;
+ /* create a copy of the skb, if needed, to modify it. */
+ if (skb_cow(skb, ETH_HLEN) < 0)
+ goto free_skb;
+
+ bcast_packet = (struct batadv_bcast_packet *)skb->data;
+
if (bcast_packet->ttl-- < 2)
goto free_skb;