๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10114

Re: [PATCH 07/14] xfrm: policy: reject mark with bits outside its mask on add

#10114
From: netdev-bot+sashiko
Date: Tue, 03 Nov 2026 08:05
96 lines
11366 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] This patch makes XFRM_MSG_NEWPOLICY and XFRM_MSG_UPDPOLICY
  reject input that mainline currently accepts and that works.

--

xfrm: policy: reject mark with bits outside its mask on add

This patch adds a verify_mark() check to xfrm_add_policy(). The check
rejects XFRMA_MARK values that have bits set outside the mask. It also
removes the mark sanitization from xfrm_policy_insert(), which commit
0b91fda3a1f0 ("xfrm: Sanitize marks before insert") had added.

> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> index cc206017d0f50..cea6842e6454d 100644
> --- a/net/xfrm/xfrm_policy.c
> +++ b/net/xfrm/xfrm_policy.c
> @@ -1575,9 +1575,6 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
>  	struct xfrm_policy *delpol;
>  	struct hlist_head *chain;
>  
> -	/* Sanitize mark before store */
> -	policy->mark.v &= policy->mark.m;
> -
>  	spin_lock_bh(&net->xfrm.xfrm_policy_lock);
>  	chain = policy_hash_bysel(net, &policy->selector, policy->family, dir);
>  	if (chain)
> diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
> index 6b53373168b02..c1571c7a23153 100644
> --- a/net/xfrm/xfrm_user.c
> +++ b/net/xfrm/xfrm_user.c
> @@ -2307,6 +2307,9 @@ static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
>  	if (err)
>  		return err;
>  	err = verify_sec_ctx_len(attrs, extack);
> +	if (err)
> +		return err;
> +	err = verify_mark(attrs, extack);
>  	if (err)
>  		return err;

[Severity: Medium]
Will this reject XFRM_MSG_NEWPOLICY and XFRM_MSG_UPDPOLICY requests that
current mainline accepts, and that work?

Since 0b91fda3a1f0, a mark such as 0xf42/0xf00 is stored by
xfrm_policy_insert() as 0xf00/0xf00. The policy then matches traffic in
xfrm_policy_match():

net/xfrm/xfrm_policy.c:xfrm_policy_match() {
    ...
	    (fl->flowi_mark & pol->mark.m) != pol->mark.v ||
    ...
}

With this patch, the same request fails in xfrm_add_policy()->verify_mark()
with -EINVAL and "Invalid mark value/mask combination". A userspace IPsec
config that loads and passes traffic on current kernels would no longer
load.

The commit message only says "Reject it instead". It doesn't mention
that this input has worked since 0b91fda3a1f0, or why breaking it in
mainline is acceptable.

The Cc: <stable+noautosel@kernel.org> # avoid breaking existing userspace
ABI trailer suggests this is known to be an ABI change. However, keeping
the patch out of stable doesn't prevent the change in mainline.

Could the lookup failure be fixed without rejecting any input? The GET
and DEL failures seem to come from the exact compare in
xfrm_policy_mark_match():

net/xfrm/xfrm_policy.c:xfrm_policy_mark_match() {
	return mark->v == pol->mark.v && mark->m == pol->mark.m;
}

Applying the same v &= m to the user-supplied lookup mark, for example
in xfrm_mark_get(), would let existing inserts keep working.

Also, the commit message says the policy can't be found "by id". Doesn't
the same compare affect selector lookups through xfrm_policy_bysel_ctx()
as well as xfrm_policy_byid()?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261102100451.2505200-2-steffen.klassert%40secunet.com
Technical Details
Message-ID: <179369310395.488856.1196610792291916744@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-355276-linux-kernel-netdev=dewy.ru
References: <20261102100451.2505200-8-steffen.klassert@secunet.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-355276-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH 07/14] xfrm: policy: reject mark with bits outside its mask on add
Date: Tue, 03 Nov 2026 08:05:03 +0000
Organization: Usenet Network
Message-ID: <179369310395.488856.1196610792291916744@kernel.org>
References: <20261102100451.2505200-8-steffen.klassert@secunet.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3119541"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:4eqMmHz7/lm5LDaAf5B9Z66uyPc= sha256:46LtMMOSvAV/XxXUu2/k0s46SIDi0n5JXUwFq3fkzcw=
	sha1:MuZ58DS/N8sg3mWplQxqukGra2M= sha256:5HP9p/x8JO8ntM2Rd9oVlFoZ7UO46do/FL8gday3Dn8=
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 1B3071126DB; Tue,  3 Nov 2026 11:09:50 +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 1RekpjJ5eO2C;
	Tue,  3 Nov 2026 11:09:47 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-355276-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id D0880112768; Tue,  3 Nov 2026 11:09:38 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 24E612A6B8; Tue,  3 Nov 2026 08:05:09 +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=1793693105;
	b=HYp3ZKt5OYpPmHC04WcmkvJoVJXHLaX0MYl2nheRlhmBKW0e6ucp8Jz2PqrqD1Z9OJnZ
	 YSN0aNZ+xkrvAdvH266mLWkqmecZXYX2WZtyY/8PzkwnQR61weF4vychF3qRN6sDi36sh
	 Ng/OYuTope4LEOnmeK4qwiryH1mpeeKVMehOjEqKG/Y/D+xPr4kZZ0jDhRi6yPs/+iFmf
	 IyAjB6oximgx+AJpxmqcIgRkw1T695TUlNGCoof8SEnY+hymx6WHAGc4Ro8chGl8mYWiI
	 EIRcrF2M4HBnST1OY7J5UXbY6yeEIRbDok0SPu/N+h6wmK5HIWpWSH15nqI59Z8ABDA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793693105;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=oCaoMThyIIQHYQEmMpnmp88aQ+J+uEIeqkVnvW0Jyi4=;
	b=tZEyZeLsKuHo+s4ae3CTre1QlXXkGbT7ZCoVuzsKz2yhrCoqwr+Prj3HAwZxNypoqVE6
	 IrRZcCXlx0OjwsAhlTM9jYIy8Zuc6fqiQBM5xDQ2p6SRlM5oT2qW9KXHLoX18D+QiQ82v
	 LCl87JwNDWuG2/SEw+sawRxgTPBp4DhQU2SdvXSFqYRltJji6uQKNYD1KzD3UmRKqkbDW
	 fp75lAsZc8Ar4OqyyRQWWNjxXl6obEu8t3TOg2JMwOD2ub38T14o9DOo60i93rzdWuwFp
	 fKw8HZv9tfSfZ5OfLprpk7sKWnoIYFnoHbKPHXcw/v6alF/MgDitDpRqgMxYTA8bnSA==
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=YpxchWOQ;
	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 DA2C1606A330;
	Tue,  3 Nov 2026 08:05:05 +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=YpxchWOQ
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=1793693105;
	b=lanBhOkzcMwRUKdU6QFn6Gz+vCojEmQrK4mhZ2K9mfSK/NHVeE14DLnyGpVukGQVyZ9U
	 me2a5NcAzjj6GyPFFAaWEx1+//fxr63RjF/U/Oi2ALcr95P0cKiSIorZziVXs6RDh8RUC
	 bumgeU2s0O+i7/frGmNYGASFaK7TCWUHIOQ8fTbXYqLCZLD1hdCefT5RThOE3kfby07wy
	 6dzE6byOrUNnhGe0P3fjX4yZogW+On8CBdaSHzAxz5OgpuAazzZnj711zlcXFAncKzikk
	 j9JwUXMz4o2FJLSlndSfbP/8PkweIrspVrN0fYTuJx2BSWbe6LHCKHxraypUXBZqRvw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793693105;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=oCaoMThyIIQHYQEmMpnmp88aQ+J+uEIeqkVnvW0Jyi4=;
	b=H4zXltwNXQW94AjmU96zOvEdZDAZQh3n9A2rCmk5iIQBbpYScfHsjqYiHLY4zFO82QbE
	 WEQu6+zzIVsHFDgZHvD3T5YA+q8m2eCz8eeq8DnxrdrHd1F2LX+dutadloKQDLJ8gbtAy
	 9YYEYhtVIDaxgEO2hkaRZiWFQzVzuQY+/GkuN8LYZzD7hXtyDd4KL2rEW7SLgfyNm5ZOE
	 oBC+Wgdb8uTkEYHEGip/9ectU/Rga001oIzlQqT55OCZad5NDrZz7XPuvBcnzKrhW4qjv
	 2C/eirleF+4BPLTBVizItgQVa/B7qvi02I3ecqP64YjC3gCXkH7Ub7mR8ETaC3YhM0w==
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=YpxchWOQ;
	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 BCCBF606D805
	for <netdev@vger.kernel.org>; Tue,  3 Nov 2026 08:05:04 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BACC1F000C1;
	Tue,  3 Nov 2026 08:05:04 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793693104;
	bh=oCaoMThyIIQHYQEmMpnmp88aQ+J+uEIeqkVnvW0Jyi4=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=YpxchWOQ5o4LZ58CP7to96hdmYu77FkroCVPKlpC3eXEqDuUjiFYoYqaAQX17LQNe
	 KV2I9/zeSgwuln8w/byo7hFEhyYrk12f+5TJPjdqJMR1S3+29ccZeVFHMvZGNTfF7X
	 8NLMS1HnGujjkBIpG6xsKrLxFVOff7mQcrzeEl8FXYpkYklfr085ryMzvL+/QjEAzY
	 8cQ37iIGkkkansvHGZ2MrGdzMbsPpjGEj51dUYNa27FE8jVT4o7eVQ6Zr9WGAtcLbL
	 yniL4g9tP3lJWckXaPjnAbAYWC46ANm+KH/QzLAVvdwAzwKXxIBoNvCYtcxP6plQeD
	 Q5Im2j2XPOf1g==
X-Cc: davem@davemloft.net, kuba@kernel.org, herbert@gondor.apana.org.au,
 netdev@vger.kernel.org
X-In-Reply-To: <20261102100451.2505200-8-steffen.klassert@secunet.com>
X-sashiko-severity: Medium
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