Article View: linux.kernel.netdev
Article #10925[PATCH net] ipvlan: make outbound skb headers writable
From: Eric Dumazet
Date: Wed, 04 Nov 2026 11:35
Date: Wed, 04 Nov 2026 11:35
65 lines
10339 bytes
10339 bytes
From: Kyle Zeng <kylebot@openai.com>
In L3 and L3S modes, ipvlan_process_v4_outbound() and
ipvlan_process_v6_outbound() hand the skb to ip_local_out() and
ip6_local_out(). The IP output path assumes it owns the network header:
__ip_local_out() rewrites tot_len and the header checksum, and
transport-mode XFRM can memmove the network header into the headroom
when xfrm_skb_check_space() finds enough room, without copying.
The skb reaching ipvlan can have its header shared with another skb,
for example after an AF_PACKET tap on the ipvlan device or a tc mirred
mirror action. pskb_network_may_pull() only makes the header linear;
it does not unshare an already linear head. The writes above then
modify the other skb. If that skb is on the receive path and its IPv4
header was already validated, IPv4 option processing can use the
modified header, write past the linear data, and corrupt
skb_shared_info.
Use skb_cow_head() before taking header pointers and entering the local
IP output path, like ip_forward() does with skb_cow() before it touches
the header. Only checking skb_header_cloned() is enough here: skbs that
TCP transmits are clones of the write-queue skb, whose header area has
been released with __skb_header_release(). Their headers are private,
so they are not copied, which avoids a reallocation for every TCP
segment sent through an ipvlan slave.
If the allocation fails, the existing error accounting and drop paths
are used. L2 mode is unaffected.
Fixes: 2ad7bf363841 ("ipvlan: Initial check-in of the IPVLAN driver.")
Signed-off-by: Kyle Zeng <kylebot@openai.com>
[edumazet: use skb_cow_head() instead of skb_unclone() to avoid
copying every TCP segment, reword changelog]
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
drivers/net/ipvlan/ipvlan_core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
index 7ad12dc7845c836bdd04395f153b2b4b397797d6..d2afc2ec896e039d174e2b0ecfd4c9ff6634cfaa 100644
--- a/drivers/net/ipvlan/ipvlan_core.c
+++ b/drivers/net/ipvlan/ipvlan_core.c
@@ -438,7 +438,8 @@ static noinline_for_stack int ipvlan_process_v4_outbound(struct sk_buff *skb)
.flowi4_mark = skb->mark,
};
- if (!pskb_network_may_pull(skb, sizeof(struct iphdr)))
+ if (!pskb_network_may_pull(skb, sizeof(struct iphdr)) ||
+ skb_cow_head(skb, 0))
goto err;
ip4h = ip_hdr(skb);
@@ -504,7 +505,8 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb)
struct net_device *dev = skb->dev;
int err, ret = NET_XMIT_DROP;
- if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr))) {
+ if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr)) ||
+ skb_cow_head(skb, 0)) {
DEV_STATS_INC(dev, tx_errors);
kfree_skb(skb);
return ret;
--
2.53.0
Technical Details
Message-ID:
<20261104113530.986664-1-edumazet@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356382-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356382-linux-kernel-netdev=dewy.ru From: edumazet@kernel.org (Eric Dumazet) Newsgroups: linux.kernel.netdev Subject: [PATCH net] ipvlan: make outbound skb headers writable Date: Wed, 4 Nov 2026 12:35:30 +0100 Organization: Usenet Network Message-ID: <20261104113530.986664-1-edumazet@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3381030"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:RA6CrvqCejayF7d/HLDPvw8IF9w= sha256:UbLkTFPJkscxFzNCxLvO4H0KhyyQLpwRWweeRGCCPeE= sha1:7hW+ick6e4c7cGRR4Ry5Zews7HQ= sha256:Cw1fWLh71ENWeeOdwEgcR14qEkAAF5Wc/E4iubIGbYU= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id DA1DD112B95; Wed, 4 Nov 2026 14:39:16 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rioXnv-Xuiu2; Wed, 4 Nov 2026 14:39:13 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-356382-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 8DF7E112B55; Wed, 4 Nov 2026 14:39:01 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 7014028FC2; Wed, 4 Nov 2026 11:35:37 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793792137; b=nd+a5sk+LNPXh/uQuh549Xj15OpwEHRq28PPSklugyOU6YOEslOJGaSKC6gViZTSlhFK oKhNa9vyeLYSTyrN5nr3xIUq3B965C9wWv0tQYzPCcynJre6esFwU9X7pGW+2zjidoQPS gIM2RpjGASaOkQo0wlXaYRjjvzbrb5oBDBkOxeXKP5idC6KopBJ4DsKtfUj3TuXuKPwrj bjUOcj3gPudChnAxQlm3brdnBHS8JmFH+XnL22schwFdJ+pJxE1oIOdcuFq0vlwEoA3uV wYERafWmBzeMrpeRK6qbvdLDxKBzsvLAIMyFU/vaZFtn3Bgaf4XoypWgT/Yo0hf5qAw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793792137; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=DiTNhjiby/N/S8aTfjpWGWUjlVo4gDdyQaJC/ra1gL8=; b=sapRr24+MMZjbgFfxy6nrCXF30OHa3nELjIr1kej8MXYg9kpEJaLGQW6MsL0XnfUaLuL TtU08wqeuM17OgkkOY/fjwowl0wNOgYU+EkQocEd9AlVhjC6HVVGXD5ZjoZ5tkRuznCfh EXcBrNpcAXLcW+Hc+OZ4DRnys4/SJO9phWILazu7tALldZEDjlN2GCkx/6EAiq75L86Ra 4pEp1SfbBIOgte6oO0mxfMjTgHMVZ54Z9R5bswF39sJDTNyxd0WaxCrHU05VWLTvHv8QQ /4u828WvkKjBS3vlrrwWSm71I6KsiTBohkxWfmQdFUkxgURIb0pA9S5xzjMCLM1BPBw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=afB2dfy9; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 478A6606A32E; Wed, 4 Nov 2026 11:35:37 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=afB2dfy9 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793792136; b=V6iiJigrNmJxin2fccTQWQydWoi9EJxKX8hCaicg2k0P5xszAKhZvkT8NiywmvJkrPih aKlOBauhkh+cwhnHtx6Kir4WNyuliT9bHtVMttUDyjSpe3QjTUNjo7cKzlkY/UaoPsNmZ KKtLgTv6m+Yl7dFr7xat8HBSfA1T+Au4vGH4Tgt22nAgMzeQ5Ki2Bt/t0eXuu76mZfCcr oq/xQVzerFdqXSCFt1Dn0Ct2N25jnjXIPh6hYSgiaUxku5+NbHFTARTqeFCaTdB7sW+sO YqmO8ZZGsllFxbxzLXSKthkV907iIf4ukhyySQDaBIQU7A3KlGlRqB9ygOVog1hNKlg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793792136; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Transfer-Encoding; bh=DiTNhjiby/N/S8aTfjpWGWUjlVo4gDdyQaJC/ra1gL8=; b=5Q5Ltuw1PfFv7Y9ol7eZtgNv8E8dIAiQdCGCKNuwc1MWG9g0jCHQ/q7jqCLMAa9kRur0 Tmu0COGStP/j+SQxf1TLEmRpb2Z2sIo47bmbUAsxzmrhfU62BFCdjgkgDU8JCjZ44kLWm Fp4XWnQkPuGRiyDeBic3n22uetNkRxLiG+hFqjLFPyFk5Gh/95kr1vMV2l6oWAmxXkcMV zVGza4BMf5/d4mzhykW0FiJqM/UgsTA6vMiuEZCLme3d+dLrSH8xhl2Z+tuxjlBx/xBJa S923H2KiWQABfL7hHDTRCozvQl3F8/VB0kxrTfYzoCCTBooeNb2MJr34sr4DHOqFkdA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=afB2dfy9; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20576606A31B for <netdev@vger.kernel.org>; Wed, 4 Nov 2026 11:35:35 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CC0B1F000C1; Wed, 4 Nov 2026 11:35:33 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793792135; bh=DiTNhjiby/N/S8aTfjpWGWUjlVo4gDdyQaJC/ra1gL8=; h=From:To:Cc:Subject:Date; b=afB2dfy9O53QJjrcOv0Qvx3ebyGft7SHbLiPWo8PLZLcjzo3GoMaM4E+9vi+Dww3Q 49pLLRcnqFD916Kb8Ty03la5kr4fGQJiKXtXyUGK5nV8RVVzV+D5KMhO1VHZ0bHe0k M5NnngZr6gyvmRnQ6d4Ti4iC4sAnqu57L7eLDwbcHrc7HaRhhIHkJKOhXHPIZuKphm YYscFPMMeKSeawMgQtDFCFkEV7OiT7I6Ec9zf/MqJTNyHOqhtU/iJX0RI0S3gEBd3d VNvBQL8VKAVR1jRkENgDJCAyF6zyRQpY/k6KQn9yn4YGaaxPCneSF4FPMWsJ3wXXo5 a+/nPx+VNM4/w== X-Cc: Willem de Bruijn <willemb@google.com>, Mahesh Bandewar <maheshb@google.com>, Kuniyuki Iwashima <kuniyu@google.com>, Simon Horman <horms@kernel.org>, netdev@vger.kernel.org, Kyle Zeng <kylebot@openai.com>, Eric Dumazet <edumazet@kernel.org> X-Mailer: git-send-email 2.53.0 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list