From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 857B9326D44; Tue, 21 Jul 2026 18:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784656818; cv=none; b=hrb6p/RUCOmRA1HVoSYrDTqfWF1sxj/sB6VS3F2BOOagJ0Fb1X713CVr7rpc/ZpIvqCp1YuMFF7cCl2kn42eWB1WDca2C+7+3Bpw+fRLqWQgVKkH6dYqyUoO6Unvfq4TKRpGV7trrmLT5s1ByKNyFgWAwMpn1HnaxyHiAtPL+aQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784656818; c=relaxed/simple; bh=KDOVvVmKwfd+CSuBHEajpF8K7/oFkQ3Z48DOO55J9jo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ux76H69BQj1jwy3iX+e8V6HO2dXA5fvvZ0jveTzaLOiqnv2pIAKW/QrdN13Y1VERxJCI5v1SpDfbVVWxmK2FX9kYdU/1gTIAJQtxnJWmt9D8d92kof2eOf5VYZlL164WLhdvkzo0rqGgprLlWiYPIm1HM6BlN6J21lr6AqHIt4Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uP+jv4YX; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uP+jv4YX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0D1B1F000E9; Tue, 21 Jul 2026 18:00:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784656817; bh=4Q7jHUYGVYnczkTJ4juf9b9/HSXn/6eJxnGmMQNYlOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uP+jv4YX242imGqqBO4jxDDK2vxk3lR6HqlNMqmf8vR9bZPzuyEn5fexvQr/r26wS YQLrC9mVItBBQRu0YKDOWw9Wuseu4BCvvmXjd7XRwuFvOpI19eKQ+LjgdsKa55ctBq nscnNb7NNl+x50bnt2gxkuZ/q2hu9Ev0VSvo5wZM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiayuan Chen , Jakub Kicinski , =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , Sun Jian , Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.18 0513/1611] bpf: Run generic devmap egress prog on private skb Date: Tue, 21 Jul 2026 17:10:29 +0200 Message-ID: <20260721152526.885268206@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sun Jian [ Upstream commit 6001896f00984d317fb75160ba05c4a885fbe2a0 ] Generic XDP devmap multi redirect uses skb_clone() for intermediate destinations and sends the last destination with the original skb. This can leave multiple destinations sharing the same packet data. This becomes visible after generic devmap egress-program support was added: a devmap egress program may mutate packet data, and another destination sharing the same data can observe that mutation. Native XDP broadcast redirect does not have this issue because xdpf_clone() copies the frame data for each destination. Generic XDP should provide the same per-destination isolation before running a devmap egress program. Fix this by making cloned skbs private before running the generic devmap egress program. Use skb_copy() instead of skb_unshare() so allocation failure does not consume the skb and the existing caller error paths keep their ownership semantics. Fixes: 2ea5eabaf04a ("bpf: devmap: Implement devmap prog execution for generic XDP") Suggested-by: Jiayuan Chen Suggested-by: Jakub Kicinski Reviewed-by: Toke Høiland-Jørgensen Signed-off-by: Sun Jian Link: https://lore.kernel.org/r/20260612114032.244616-2-sun.jian.kdev@gmail.com Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- kernel/bpf/devmap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c index 5b9eac5342a90d..dc7b859e8bbfda 100644 --- a/kernel/bpf/devmap.c +++ b/kernel/bpf/devmap.c @@ -710,6 +710,18 @@ int dev_map_generic_redirect(struct bpf_dtab_netdev *dst, struct sk_buff *skb, if (unlikely(err)) return err; + if (dst->xdp_prog && skb_cloned(skb)) { + struct sk_buff *nskb; + + nskb = skb_copy(skb, GFP_ATOMIC); + if (!nskb) + return -ENOMEM; + + nskb->mac_len = skb->mac_len; + consume_skb(skb); + skb = nskb; + } + /* Redirect has already succeeded semantically at this point, so we just * return 0 even if packet is dropped. Helper below takes care of * freeing skb. -- 2.53.0