Article View: linux.kernel.netdev
Article #13212[PATCH net v2 2/2] cipso: unshare headers before recompiling IP options in cipso_v4_error()
From: Eric Dumazet
Date: Mon, 09 Nov 2026 13:17
Date: Mon, 09 Nov 2026 13:17
49 lines
9642 bytes
9642 bytes
cipso_v4_error() recompiles the IP options of the offending packet with
__ip_options_compile() before echoing them in an ICMP error.
__ip_options_compile() updates Record Route and Timestamp options in
place.
cipso_v4_error() is called from the LSM socket receive hooks through
netlbl_skbuff_err(). ip_rcv_options() unshared the IPv4 header earlier,
but at socket delivery time the skb can again be a clone sharing its
data with other skbs, such as the per-socket clones made for raw sockets
or multicast/broadcast delivery. Writing to the options then modifies
packet data seen by the other users of the buffer, and a concurrent
recompilation would hit the same check-then-write race as the one fixed
in ipv4_send_dest_unreach().
Make the header private before recompiling options, as ip_rcv_options()
already does. If the copy fails, do not send the ICMP error.
The issue was found by an AI code review agent. It was not reproduced,
and the fix was only build-tested.
Fixes: 3da1ed7ac398 ("net: avoid use IPCB in cipso_v4_error")
Reported-by: Kyle Zeng <kylebot@openai.com>
Cc: Paul Moore <paul@paul-moore.com>
Cc: linux-security-module@vger.kernel.org
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
v2: no change.
v1: https://lore.kernel.org/netdev/20261106234313.2537882-1-edumazet@kernel.org/
net/ipv4/cipso_ipv4.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index e65a3f29d2caf31c34cc5aaaf862257d7d374275..f5f6a812ab9ef05117e002779baf136e615c043d 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -1725,6 +1725,9 @@ void cipso_v4_error(struct sk_buff *skb, int error, u32 gateway)
* so we can not use icmp_send and IPCB here.
*/
+ if (skb_unclone(skb, GFP_ATOMIC))
+ return;
+
memset(&parm, 0, sizeof(parm));
parm.opt.optlen = ip_hdr(skb)->ihl * 4 - sizeof(struct iphdr);
rcu_read_lock();
--
2.53.0
Technical Details
Message-ID:
<20261109131736.3060756-3-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-359326-linux-kernel-netdev=dewy.ruReferences:
<20261109131736.3060756-1-edumazet@kernel.org>Show 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-359326-linux-kernel-netdev=dewy.ru From: edumazet@kernel.org (Eric Dumazet) Newsgroups: linux.kernel.netdev Subject: [PATCH net v2 2/2] cipso: unshare headers before recompiling IP options in cipso_v4_error() Date: Mon, 9 Nov 2026 14:17:36 +0100 Organization: Usenet Network Message-ID: <20261109131736.3060756-3-edumazet@kernel.org> References: <20261109131736.3060756-1-edumazet@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="364565"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:dVQXqmoUwx92vYmwj+8STkzmcPM= sha256:622wETPl5YvhFON9iCP0euCxTInYcxE0yZjpMt3qd9c= sha1:BpepjnN2rHO1YruI+kJuCTJJBWs= sha256:mQy5wjSOeYLdgKYoua4Kjb3Gz6gICX0IpcCTAO9V4UM= 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 8FD0B1137FF; Mon, 9 Nov 2026 16:24:18 +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 RmAClKv1dYqq; Mon, 9 Nov 2026 16:24:15 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-359326-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 ABC8F113780; Mon, 9 Nov 2026 16:24:05 +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 C0053107CCD; Mon, 9 Nov 2026 13:17:55 +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=1794230275; b=J1dzP19V+WePG9mvFv4rnb5/4Hv6b3E65y57m99kLkucPwStInfNypaK0YwvJlNrAEmT Q851aWTLYW9SQ/+IfSMCLjQFAEyzJeg1rQ+ynBQxNC670+Xjd/qDwlL4SwL67Z3XnEE/r w7NAJnj1oSXNRQb/Zg57b/oZeEKlya41SAcRf/ZKHDrQq79ERsi9GkBLkyW+nB59sdyCM hOGWlsWCOCr9MU1AIkLgvsNd1ZX8AejUjDuy30Gxyp7sCKGup1XUnBgJzT13jdGS6oD5z sBVkkxC+BIXpLV8JtV50S+p4wQ8IijzA2Ge7itpc9j86fTkKMc7PHjzz3n/sk8XAEDQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794230275; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding; bh=L30ylyi7mcSbO4q1PzcorbnCHicUdcb120q9e+UTDeA=; b=Uxd5iVYD132YllPY1VZr9UkOV+mNlXfIV4zIc8TIySiTS0getDg5JMoIB8AVQ7qNaQsS JYLO0wWk9SAHep5wrsEw4nfPUO/mosGqOa424PASBkVx55kJophXxakkj+Q371d9GasJP ap71hyx2fpq/tlKrCWYwa801sH/nC49wV1gV9g7i5w90TZXSRLZOejFGUF/dmg4uM5FoM NWNP0/tYQdY1V6Bax+/WRCBf616fXUKO3TfwaDZH6gwA1sTI32q/pUkMgCIhaTqkM1st4 4vcMIgtpY8iyayvrsmPu22XjNfo6dhSMqx2MDxqJwsPbKd/IGYFQGZIMHunE5wwkDUg== 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=DmONt9zn; 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 21364606A332; Mon, 9 Nov 2026 13:17:55 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DmONt9zn 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=1794230269; b=5ktCL/m6M19uSTox44gErVfLJwTW23LNKe+nbzLlufmZzWBUxDL9RwnV5qO1DFKDmuCl 1MGbEmWGWhFrUYt1ONwm15IVdbuo2SQBM4VzZqkvexH8Y46aHEbAkSYAp1uyWDSUSPN32 U7aZ/E4PDvn8wlfQsaugY2pP6ABjb/PvNOev/eheajT+uFNhobtY+NASrcf17BqKoeKxC CvD23u6lvJvgWYzzbDswhx8x29N3xMVOTE5kepMEY50+UqpUNQMLfXa5YQLH2zyUv/soi LQGU65qTvLpjrm2A8oQWPiNhv1uqKyk1GF1qaxfW0lBMx4L6cIFaqQto4Hl8/QV4gUg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794230269; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=L30ylyi7mcSbO4q1PzcorbnCHicUdcb120q9e+UTDeA=; b=1RtfTd4lridFqKjpdHzyT8xjnFLJN/80b1oOJheZlWP5i4LHN0/MI4FkO9zw5krdX9El +geRrSWN+SV66EhH6OtCtIdDckou0J1Bvg+8HayqXAinkJVJFVWAuG4SdTTjOLHuAwNDf 4Jfg/VJSHKuNEO2yZiFLkAd5rTKQMJPQrqLXnhy5PiPU1ccZZE+o4DvASzuKd834gX+V8 F/4s3rwqtrHt+Rolm//GAEUXCNRNrlMx3/d5ANiR33GmCvrc6DJdqGTbCqS45WXhOCRfi V5ksz8T/jfxZYD8LDNILfvpCufhqGXabIyyEw8XhqlYrLcqcjsz+q9imhiuJCFU/EPQ== 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=DmONt9zn; 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 013BA606A31C; Mon, 9 Nov 2026 13:17:48 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CDE41F0089F; Mon, 9 Nov 2026 13:17:46 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794230268; bh=L30ylyi7mcSbO4q1PzcorbnCHicUdcb120q9e+UTDeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DmONt9znjtDiZc2ocniAOT2x05E7BFrIowImhqr+WG0CHuGFUjWF+Jr4KFjsMFvMy pJGErvFmtX5tl8lIJ96Gt93hdV0SAml86HAcd7nxKGXwUgCA55ovYnBq+648BPnB2p bXj8m3LjtM0edmhh/GerPVfV/yXUdoECeXlptowTYSUpZjrVEYgABQ6jYAPhqktsd7 8yGNBrkRmHmiCHVi9B4sNL7h3qu491rqnPKpi6+2+XoAAMrX51xaOjDDyGzrjW9Qjs nYOVHgj3bKRdvRHrwCD6SmP2/RlDzE4RvlG6pP6a+bjls8yrivho0spaR92RBVxyPQ v8sj9wqezug6w== X-Cc: Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>, Ido Schimmel <idosch@nvidia.com>, netdev@vger.kernel.org, Eric Dumazet <edumazet@kernel.org>, Paul Moore <paul@paul-moore.com>, linux-security-module@vger.kernel.org, Kyle Zeng <kylebot@openai.com> X-Mailer: git-send-email 2.53.0 X-In-Reply-To: <20261109131736.3060756-1-edumazet@kernel.org> 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