]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
batman-adv: avoid OGM aggregation when skb tailroom is insufficient
authorYang Yang <n05ec@lzu.edu.cn>
Sat, 14 Mar 2026 07:11:27 +0000 (07:11 +0000)
committerSimon Wunderlich <sw@simonwunderlich.de>
Sat, 14 Mar 2026 07:29:47 +0000 (08:29 +0100)
When OGM aggregation state is toggled at runtime, an existing forwarded
packet may have been allocated with only packet_len bytes, while a later
packet can still be selected for aggregation. Appending in this case can
hit skb_put overflow conditions.

Reject aggregation when the target skb tailroom cannot accommodate the new
packet. The caller then falls back to creating a new forward packet
instead of appending.

Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
Cc: stable@vger.kernel.org
Reported-by: Yifan Wu <yifanwucs@gmail.com>
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Signed-off-by: Yuan Tan <tanyuan98@outlook.com>
Signed-off-by: Xin Liu <bird@lzu.edu.cn>
Signed-off-by: Ao Zhou <n05ec@lzu.edu.cn>
Signed-off-by: Yang Yang <n05ec@lzu.edu.cn>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
net/batman-adv/bat_iv_ogm.c

index b75c2228e69a652c21f240eafa5bddf25261b06b..f28e9cbf8ad5f267b3e3e3004d3769f3291325ad 100644 (file)
@@ -473,6 +473,9 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
        if (aggregated_bytes > max_bytes)
                return false;
 
+       if (skb_tailroom(forw_packet->skb) < packet_len)
+               return false;
+
        if (packet_num >= BATADV_MAX_AGGREGATION_PACKETS)
                return false;