Article View: linux.kernel.netdev
Article #12378[PATCH net 2/2] cipso: unshare headers before recompiling IP options in cipso_v4_error()
From: Eric Dumazet
Date: Fri, 06 Nov 2026 23:43
Date: Fri, 06 Nov 2026 23:43
46 lines
9552 bytes
9552 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.
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>
---
The issue was found by an AI code review agent. It was not reproduced,
and the fix was only build-tested.
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:
<20261106234313.2537882-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-358240-linux-kernel-netdev=dewy.ruReferences:
<20261106234313.2537882-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-358240-linux-kernel-netdev=dewy.ru From: edumazet@kernel.org (Eric Dumazet) Newsgroups: linux.kernel.netdev Subject: [PATCH net 2/2] cipso: unshare headers before recompiling IP options in cipso_v4_error() Date: Sat, 7 Nov 2026 00:43:13 +0100 Organization: Usenet Network Message-ID: <20261106234313.2537882-3-edumazet@kernel.org> References: <20261106234313.2537882-1-edumazet@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4003587"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:C99W93rdEMiUYurV70peNBvLMOs= sha256:VnlcWudZi38eWP9e35u5dd9g5fZQg+zqO3UYUqoWdwo= sha1:HsljoOGwSgfDHQpja3dCvv6ZiwM= sha256:9DtWLcfAocdCxLVxObFt/hDflGZj5J01zMObZFJm204= 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 CEE48113357; Sat, 7 Nov 2026 02:44:09 +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 0uwDZYiuq6um; Sat, 7 Nov 2026 02:44:05 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-358240-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 725FC11336C; Sat, 7 Nov 2026 02:43:56 +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 BD6542AB30; Fri, 6 Nov 2026 23:43:30 +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=1794008609; b=OOC56hC+3wre9P3/eLH0VDPNzmtDfrg1sN7P08q9wyUDyKrMiNj7C3aLSbzgAKU9dDKf PiG2aFuRFAOQJMJrQLvq/Ex2qOjVgUixGtFuLPvIte+TaDQcYJr5x6yk2xQWvD0lyTwn+ Rj0drDzFBh4UNIZHcWoZwCHzdGYteEKygOlWzu+XH5YcWpHSK/uVgqYCd0lozzqaZnGB2 Bi8dYkGpfXgp/Pb0eP9/OAH8A9+C3t+Xw48tkpwwDIyvB+QWQsKHv292win2Z639BQbpr xrUC5H22Ifp1tgRBQLCpSWfZ9fHvPdClme8mDtP+Pi70if0lhDS8vwIxuIcfszIEF/g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794008609; 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=QVYCLJ6CEJWYYPlOW6sPkRq4yF+frQ+0NRtoT4sY5ug=; b=lA6qDjYuk63ka6LT1T5zCktkPCbNtTZSRvekVSC5BwrCVj67d3SQMdO9amAisTMomWbt kcPTvZUdebL4AaR6UjsaMH+TLOXj0wnPZzsEbTgZ+wH3a0DJEk9/qYjz9K8lL5xBgDjo+ 4SgZw1vUzGHAyNAW1Vv2SVcc21MxVnbVCFpRRg6nBQOWAiDuXdPH1HbLC4hbEUTnL5twQ eEeL45noiIeixsE6WZb+GginEVWrXBwSTDPh4apRPw2M8I8A/Y6rKwXW1lps08iaIgdXz ilgqsPs9zkdIju8fNkngdctph+P9UBvk5ogJZm7IioUBCng7IYM3DXh5k4UrbUd1SPQ== 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=hSNRz9cJ; 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 BF669606A33B; Fri, 6 Nov 2026 23:43:29 +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=hSNRz9cJ 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=1794008606; b=VVAPGJRdjGnUcliGAycRx3T8dFX7sZDc82xOCrV/HtjGq0KNRbIh/8U+ZX010bgbks3D GAkqvrKLJCIz55YSNf62Pe99z90lulXHqrT4VuwSKEsWoSXn4LYOaHAMLCk0y47XbAJOV qMqQjrohwWhbk1zQuVk/StegIgu7NXDDeyuaSvLCnpGAI8MhnJy6N6euEgvbPSVezDBvx yrCRKh3I5Jxq9gjybx06hDMq9WYVv1I0aXPaELSasmzTyzkOE8UlrOccwoKps0BYVolsZ hCkMmVqkeQEElAE84W0KO8/RpIdV+zKaDFxiJRkBkXAXd2WscOlY8t0AaK4QWPQD5PA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794008606; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=QVYCLJ6CEJWYYPlOW6sPkRq4yF+frQ+0NRtoT4sY5ug=; b=I/aUL3nnI12xupeAvFBCEt5Y1VmMYJf27II92pWZdi1Q3Tk9TWh0UP8OllpJiNwlgSCL ms5URpPLCOVFZCYYgnsEzh2dhDSlfFvtIEPN2nMjqbMEgONQpDF9eKaoMVlG2cw3rMp8Y 5LGFNOkiwlU7s9h+x9q2H7QEby1ciGQqEZhMYagWuKOYMZL66HzD7pL9JSw3RNKPMy5Zq o9sPSX1XW6IjO84Dvpx3tGjJmt4q4viVtYdvBTfKGwJM2gUXFsEE3w9gql7z7idUZoEh5 2uw5+f1jIR02qRUmq4BOal4ChoLJixMH2BFC/qf2pYkBmN+j+TGl0FJR+N4SIravfkQ== 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=hSNRz9cJ; 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 937AE606A326; Fri, 6 Nov 2026 23:43:26 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCCCF1F0089F; Fri, 6 Nov 2026 23:43:23 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794008606; bh=QVYCLJ6CEJWYYPlOW6sPkRq4yF+frQ+0NRtoT4sY5ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hSNRz9cJ7j+EipLujJzjC6F3dpPPhfWG4o0ncn2h5iS+umqahFXaiDXKU8fgH1hKu Ptv5g2/+nww/hbtA/MkKTN/mUmDjBt3CX4cGNVIwleRKflhBjqciwtTf8xTn+3QHhu r9kmIxK6zcDtMPVLSkyDSVkc7IEMRHFOilN1jblKbrPrpnGhL4B782Vhyp8Oy2iZoD 3xbPxUYJO9pAI51fvdez2mCeXrC+XuwPaPdrl8ay9aSHdsKGVGfC397MgKIB3HIEJ6 Zg4xqKv/1SaJivO6cSNiK0m1Vvm3tbahcMLaGiNGo9KG5Ss2q/VaEzCf5+zFDB/zDp dCbrD8sLvw4mw== X-Cc: Eric Dumazet <edumazet@kernel.org>, Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>, Ido Schimmel <idosch@nvidia.com>, Paul Moore <paul@paul-moore.com>, linux-security-module@vger.kernel.org, Kyle Zeng <kylebot@openai.com>, netdev@vger.kernel.org X-Mailer: git-send-email 2.53.0 X-In-Reply-To: <20261106234313.2537882-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