🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12356

Re: [PATCH net] cipso: stop modifying live ip_options_rcu

#12356
From: Eric Dumazet
Date: Fri, 06 Nov 2026 23:06
40 lines
10771 bytes
Le ven. 6 nov. 2026 à 22:40, Jann Horn <jannh@google.com> a écrit :
>
> cipso_v4_delopt() operates on the ip_options_rcu of a socket or a request
> socket, and tries to remove CIPSO options from the middle by moving all
> subsequent options.
> That's not allowed - ip_options_rcu can be read locklessly and must always
> be consistent. For example, ip_options_undo() reads trusted offsets and
> length values from the options buffer.
> Fix it by doing the modification in a copy.
>
> The core change is in cipso_v4_delopt(), the rest is ugly plumbing to
> propagate memory allocation failures.
>
> Triggering this bug requires that the system is configured to use CIPSO.
> (Setting up CIPSO requires privileges in init_user_ns.)
>
> Fixes: f6d8bd051c39 ("inet: add RCU protection to inet->opt")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jann Horn <jannh@google.com>
> ---
> I've sent a separate mail with a reproducer to Paul Moore.

Reviewed-by: Eric Dumazet <edumazet@kernel.org>

Side note, not for this patch: Smack calls netlbl_sock_delattr()
and netlbl_sock_setattr() under bh_lock_sock_nested() only, which does
not exclude a concurrent lock_sock() owner such as
setsockopt(IP_OPTIONS). Both sides can then kfree_rcu() the same
old inet_opt. This already exists in the "cipso only" branch of
cipso_v4_delopt() and in cipso_v4_sock_setattr(), and with this patch
the copy branch has the same issue.

The rcu_dereference_protected(*opt_ptr, 1) in cipso_v4_delopt() hides
this from lockdep. Smack should probably use lock_sock() like
SELinux does in selinux_netlbl_socket_connect().

Thanks !
Technical Details
Message-ID: <CAL4Wiiob6K=Y1ne0G+8L6b8fxNxdCz3z+THgCiCBX_5MjtSzcg@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358215-linux-kernel-netdev=dewy.ru
References: <20261106-cipso-rcuopts-v1-1-31ae931d7a0f@google.com>

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-358215-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] cipso: stop modifying live ip_options_rcu
Date: Sat, 7 Nov 2026 00:06:39 +0100
Organization: Usenet Network
Message-ID: <CAL4Wiiob6K=Y1ne0G+8L6b8fxNxdCz3z+THgCiCBX_5MjtSzcg@mail.gmail.com>
References: <20261106-cipso-rcuopts-v1-1-31ae931d7a0f@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="3997319"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:hrbeVtR3RZ0bbSoyF45nxD1H4UQ= sha256:eAX2AOszxc8mDNs5mYu9jbwCPyotQDs0a5HWzKsrKYo=
	sha1:Yx3BSwaXQif4Ksv65CQI5EoGNp4= sha256:9vW1J21DDOp0XMKDfrixiM3HEMM5HXurqXyvl3zBNQQ=
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 3856A11336E; Sat,  7 Nov 2026 02:07:29 +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 T705OLTuHlgP;
	Sat,  7 Nov 2026 02:07:22 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-358215-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 0C367113349; Sat,  7 Nov 2026 02:07:14 +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 B51312FBC9; Fri,  6 Nov 2026 23:06:53 +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=1794006412;
	b=XctVVLd+kTIBhgcJ/50b0YQJ/kRocWfbXRucJnbi5iPUZyPeIZE1cW+2ZeplxXShKCUF
	 GkMT/ICf1YdCfi1G7HOzSZQlMWINvcO+RpgV7e9Ew0LC3xrtliAaSeHIIGRWyU/jOwslP
	 jaQ0MDmDq1CIkdOdrLsXiXPT38ZdtyRXUwM7gvQcrGhBneOAa5bTdss/KsTSiFfCTaii4
	 YrgccoOa74Mxzg5Y95GI5sELl2LyBl3f9H7Nl2HFI9PAd2Fw1muxPc5b0zyynjE0XCGH0
	 z/GqC5SIBrAA3BvvT7xrYp3ebGbqe9qZzTVgljtb2nIfdosN4sUsDaeKFD7w46fIZzg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794006412;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=OVffpMJpscIOft4NV2Jq0DE8YsEUp+bRS1xd5OErd84=;
	b=FTeCN+toAxXzmETNJPJoCa3IDQeUv6M4vpsEJyzJ6w3hongGLCLmsR2E2L9RnpSA2r2d
	 8jlAGhu3jVRsvY3dMHwTNBXi3zaSFl2cwODn2Z+4d719okef8sMyNQTWd/0mOu0znXRWO
	 rFkiEm2dDY672cJPSIfMHCknByp+66acZu70sxXum6+dbY53lHrMRzw05qTIC0WDbeGFU
	 CpAEwcFTiynvFNVEFdaJxoDZBlOx6sMo/A+NJF98rIUiW8VKuuwas9P8RTYBKqGC6Fbkj
	 y+/UWb6puwX4WkurdxCy8ljIVD9yHVDKp43L6iwKyBh+nbMS79h5KvFCAdPXu8g1qVQ==
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=OYwNIh8Q;
	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 8A2DC606A32F;
	Fri,  6 Nov 2026 23:06:52 +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=OYwNIh8Q
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=1794006411;
	b=E2oyflrhTd4RRdzfiRERDNEgPLOnU5D36iCBIBuAFnuSFMJDW1x3QH+bqZH4v+axaa2D
	 dKcMbK243XpQUQDchMj9J3JgrRt/BsK6glx4ZLqJ7C3lfhEcowevBCS2VMmuVrr/tRAnN
	 VIz3JdexWJZYScafASmojSZ1N+WEEo0EDxAqguN/k9oDnHeC1yVjZXyTUL4Z5DVWKPpt/
	 QsNdbX0+L9kpAYjLxAI2fi4L3dM7CyKIco1CBwB0gyPoa2S3VAsbe7wEulPo/24kgD4Vl
	 TsbqYYLPm6Tmp8rsw7pirDPzGLmT3x3P44CYrLx78hBmAU93qIEkODuUZFZFwbw2O8w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794006411;
	h=Received:DKIM-Signature:Received:X-Forwarded-Encrypted:
	 X-Gm-Message-State:X-Received:MIME-Version:References:In-Reply-To:
	 From:Date:X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:
	 Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
	bh=OVffpMJpscIOft4NV2Jq0DE8YsEUp+bRS1xd5OErd84=;
	b=19xKhNJ8HwF/gZMvl+Qnsv9ALLmKCp9+jP26xna6MzGZ0dPxxs/G5TlTSwL7dNZ0Jhyf
	 37F7Qg/6Eau4Kaa0HmYMKh2fmJ2z3KNsfQnnenUwYYPg4qcnLvaFXibFHVgAWppY4NPTJ
	 YHum/aF0Ra8OWaeePbxEFnmuDY2FKBn13BU+G0vuisw+45hAQu+e4TFh2c4lW/z+ZuHEx
	 OKpK6rs8gVIIzPuOwOy0yJWapizOACvHcJm/FWf81TH0fYWPFDWWMXqtRQHIjJVsH9C5U
	 oYhjncsxfk4TkJBDn2DpLYRYYerwQyFrb2HIlzCmTqJBDMP+Al8KbBClp32n6jUSxgg==
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=OYwNIh8Q;
	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 6B9F9606A32C
	for <netdev@vger.kernel.org>; Fri,  6 Nov 2026 23:06:51 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33F0A1F008A5
	for <netdev@vger.kernel.org>; Fri,  6 Nov 2026 23:06:51 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794006411;
	bh=OVffpMJpscIOft4NV2Jq0DE8YsEUp+bRS1xd5OErd84=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=OYwNIh8QKo6/ciABJWZoZQ2F11ZJxzpsNlhkZ8/01rtd6f6oTTOdG1NxYR1HW9KuT
	 LHEuJThM6xdBL1T7dj+RSPuu3ZR3wZBj5+lsFciuyUk5TgUIFP925g4XwXCptwPrdS
	 cSGyEK2GDAjS4l2U7gLx29alPdQIGAbIofczc2ymmR0Ex1p8NQ7ObdTracIRtb7izs
	 dblSPzucqwbwi2KyXyuYqjlEwKOqbdIW1AiqyzDkYGpDcanjOBNjZIdgtIciMT4KAK
	 qX01LM2nNseoFhTVU/yeSZtXrxtvpZKax5Cw33IApSeqsQFrNfF8wUNucNfRwPdFje
	 IQussb2MR1O5g==
X-Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-84d5e56f876so847354a34.3
        for <netdev@vger.kernel.org>; Fri, 06 Nov 2026 15:06:51 -0800 (PST)
X-Forwarded-Encrypted: i=1; AKwUvBy3wPQ+Rwi90rF9rq6QT1VBWDU3pbt+LsWCnIzmn3nNol3ctutWF/8KwykjL+gs8tTGkBNdMmI=@vger.kernel.org
X-Gm-Message-State: APuU4Z9QbDtTIE+xn09oI2jleNV8GYPveBjSr3ZnIm77XHWRNUQ6bbMC
	1ZixvspATuQ7Q/zK1YFZn/9WhlThn6ycxR2YBVxNU0smtH8I+rxGmkSivQWbkrkMxb9QQUDORZn
	jXltks3+9IjD5B/XQgZJ8sVv76h/4HFE=
X-Received: by 2002:a05:6830:2693:b0:82f:5471:4dd7 with SMTP id
 46e09a7af769-85f1d16d8f2mr4156210a34.30.1794006410384; Fri, 06 Nov 2026
 15:06:50 -0800 (PST)
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
X-In-Reply-To: <20261106-cipso-rcuopts-v1-1-31ae931d7a0f@google.com>
X-Gmail-Original-Message-ID: <CAL4Wiiob6K=Y1ne0G+8L6b8fxNxdCz3z+THgCiCBX_5MjtSzcg@mail.gmail.com>
X-Gm-Features: AclHuK85IAMcn42mvCatif5dGLCxV02KCNk7hXkKoMekgYmtNrFJzX8kSNTk-t4
X-Cc: Paul Moore <paul@paul-moore.com>, "David S. Miller" <davem@davemloft.net>, 
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, James Morris <jmorris@namei.org>, 
	"Serge E. Hallyn" <serge@hallyn.com>, Simon Horman <horms@kernel.org>, 
	Stephen Smalley <stephen.smalley.work@gmail.com>, Ondrej Mosnáček <omosnacek@gmail.com>, 
	Casey Schaufler <casey@schaufler-ca.com>, netdev@vger.kernel.org, 
	linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, 
	selinux@vger.kernel.org, stable@vger.kernel.org