Received: from dvalin.narfation.org (dvalin.narfation.org [213.160.73.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58C3A3EB81A for ; Fri, 26 Jun 2026 16:11:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.160.73.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782490273; cv=none; b=UC3LEAZkgmGcHorKmYva/bfFgmwVa+H1SbQDGpYsPapMDAD7cyqC4194plUmUT2/hPhwhGirnfHygPEfxgGKuMaGQ4KF86oT782E/a4Q8RbmzmvDcROGYZW859WnNlspOuN6kHA6No7TGihDqsS3nWwchM9sb2+8WrnYx9JyrtM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782490273; c=relaxed/simple; bh=duNf0OVl43U5AtYWagX7unQs1991m2R6G0sFeIpWXis=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CYBWPE3qkc/IOunuaLfZYF404RSWzDCd37kcaeWKcKHU8PM3xXLdHfQv8KvjOmrB5vxb1CwQfX9Zo97LzSA/LgyWKw474BjvqPCyGjCIkFX2Sb1yk61v1Nq+pBmS03sxRst4dSw1UuR5e7Qq0bMKm5oxdk11h2HhlPFfM3EUEhE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=narfation.org; spf=pass smtp.mailfrom=narfation.org; dkim=pass (1024-bit key) header.d=narfation.org header.i=@narfation.org header.b=ZT6cKMfq; arc=none smtp.client-ip=213.160.73.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=narfation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=narfation.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=narfation.org header.i=@narfation.org header.b="ZT6cKMfq" Received: by dvalin.narfation.org (Postfix) id EE7FA203FC; Fri, 26 Jun 2026 16:11:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1782490271; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GBQYwZlMffDLgoNK7pxSWrzt1huEa+SAY6YcBJQz59c=; b=ZT6cKMfqrm3VXiod1dTO+q+pS45XCzGSWQNdhoWrd9Wl5Kqnsbf/f4mBNCTaiTVD1fj78K lGEkfSSfDmtCPus9uglFeS8k+IidIVVAh2kA7+9SowX+qXNz0S8HrZmOlicNScEelA99a2 Lj3W5yODKfM7gBvSj0OqdqiDueMWv6M= From: Sven Eckelmann To: stable@vger.kernel.org Cc: Sven Eckelmann Subject: [PATCH 5.15 12/25] batman-adv: ensure bcast is writable before modifying TTL Date: Fri, 26 Jun 2026 18:10:51 +0200 Message-ID: <20260626161105.124113-13-sven@narfation.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260626161105.124113-1-sven@narfation.org> References: <20260626161105.124113-1-sven@narfation.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- net/batman-adv/routing.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 970d0d7ccc981..503c8c9381ebe 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; -- 2.47.3