🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #9513

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

#9513
From: Steffen Klassert
Date: Mon, 02 Nov 2026 10:04
48 lines
10784 bytes
From: Antony Antony <antony.antony@secunet.com>

Same issue as states: an invalid mark/mask is silently truncated on
insert, so GETPOLICY and DELPOLICY can no longer find the policy by
id. Reject it instead.

The mark is no longer sanitized on policy insert.

Fixes: 0b91fda3a1f0 ("xfrm: Sanitize marks before insert")
Cc: <stable+noautosel@kernel.org> # avoid breaking existing userspace ABI
Signed-off-by: Antony Antony <antony.antony@secunet.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/xfrm/xfrm_policy.c | 3 ---
 net/xfrm/xfrm_user.c   | 3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index f6f40ba713d5..0f6fcea28bcd 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 6b53373168b0..c1571c7a2315 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;
 
-- 
2.53.0
Technical Details
Message-ID: <20261102100451.2505200-8-steffen.klassert@secunet.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-354521-linux-kernel-netdev=dewy.ru
References: <20261102100451.2505200-1-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-354521-linux-kernel-netdev=dewy.ru
From: steffen.klassert@secunet.com (Steffen Klassert)
Newsgroups: linux.kernel.netdev
Subject: [PATCH 07/14] xfrm: policy: reject mark with bits outside its mask on add
Date: Mon, 2 Nov 2026 10:04:05 +0000
Organization: Usenet Network
Message-ID: <20261102100451.2505200-8-steffen.klassert@secunet.com>
References: <20261102100451.2505200-1-steffen.klassert@secunet.com>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2877267"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:1XDPvAzs1a59OyZCQq5lNmrLqKw= sha256:eE9jogaUNXao9Vp6RULOmz8ai8fIrJRV7XOp3Tr+8Sg=
	sha1:l2/ssQUQvPUsXz6AVhGk1UodBS8= sha256:xYLfM4uF3f0UhIeKm17ROJjN3p1jUVnwvjt8r+uRfvc=
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 55E86112451; Mon,  2 Nov 2026 11:05:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.15
X-Spam-Status: No, score=-3.15 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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=secunet.com
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 7pl021GMo_tg;
	Mon,  2 Nov 2026 11:05:51 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-354521-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=secunet.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id EC969112423; Mon,  2 Nov 2026 11:05:42 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id DF8CC605FAD; Mon,  2 Nov 2026 08:05:08 +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=1793606695;
	b=1WHAa7qQzwAPOGPYF81KpCU223DjC5IczF6xxRKv9rURCvUEXKK+Gh/aL5oOLYu23bBc
	 aUoRPgX/AY7cxU50rCSo58j9qGmcdEuzmjnTVNkeSQTtBaWOGBG+TpeVj/PeRBcUsP54o
	 69WE/pmCKNQrcL9gBy4fWNGY9GocU3WdbatiC6Nw/SJHQ0SYQAI/zMNidK2w2wMmg0nSH
	 dUlm6NlK8wG1vKEyzHV8KFfuIjDin/xvhttWymN6IsAc/i3xGYOMkQGUn/GcHtoXaOx+v
	 xAhtBAmhWu0QklRP4lQWTTBQkd/gkXIANHkdYMqkCzwLzDZE+r0/8RKubrH14Qeud5g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793606695;
	h=X-Original-To:Received:DMARC-Filter:Received:X-Virus-Scanned:
	 Received:Received:DKIM-Filter:DKIM-Signature:Received:Received: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:Content-Type:X-ClientProxiedBy;
	bh=4+A/IPtr1zAGWJVL6F4Lv/Y3Q75zd4cJs2PSxPvnViY=;
	b=IO2+Xt1N6wcyFVbpY6C1EXs4pSefaj7os3FGSwvHXBSMzX2th2+xktQAJJmi6lF8Kmqg
	 aEuve2fYgmWqnIf7a4P8RrOj5Yt62J5nTmeeon5DXHFj1YZZ2AK6wJezjFErZb8aokiHp
	 sr8xKv1RrctKP+nflk+FElj5GzCX3lvnRzbupvnx0XYQLZGNQRaHS7Eol28q5fy39HJju
	 3FZwAUcFN/PTcivuT202P4puzyEwUifa2rGFBwNahBKufjVCkMGOIAB/M2G5VUDEJbtNS
	 v31wXxDVG9IS4Enb6gQUpoIEqpzoYXjvMiVUyoChydHy4B0tNz00q0YoOj+24+I6O1w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=jmnDooWB;
	dmarc=pass header.from=secunet.com;
	spf=pass smtp.mailfrom=secunet.com;
	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 F226960A3816;
	Mon,  2 Nov 2026 08:04:54 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=jmnDooWB
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=62.96.220.36
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793606694;
	b=YdSiu+Zv6THKXJ+sdA+bZIOAmqWXLRA0kSipfl7xL9uvB3S94TVOhl2OwLHeQwdcLO/Y
	 YEMYzcEpgsk7jj2rAvnysoTi76su5P8gY6K4znaUTkF9386mVyEvIJQyxbiStpnIwc6MT
	 guSAiSGWs0y749QEyx2rSgIOTgCGTTpLFLP8pn2WCoXOrMqvPJL3OrafYFI2kC4j6e0tf
	 Bzm5tLi6hlhsteZiF9GOhF1m43jY3k0daIXACiGN/3A5uX6yrgibT7MLf+XhifWw6obLb
	 zP1I096B9c+KoFZRWPA8/afOQ38oHHW2f8sLrOAK7XJ1jslWE9aE+WZCOL0UZoRN5Yg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793606694;
	h=DMARC-Filter:Received:X-Virus-Scanned:Received:Received:DKIM-Filter:
	 DKIM-Signature:Received:Received:From:To:CC:Subject:Date:Message-ID:
	 X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding:Content-Type:X-ClientProxiedBy;
	bh=4+A/IPtr1zAGWJVL6F4Lv/Y3Q75zd4cJs2PSxPvnViY=;
	b=c2K27zrbSckBrs8FXSQoxBzKmYok66JDLa1trReqcqnSN9a3clgVc/vgtspsTFMmLahd
	 TJtj5dooeJR9mdiv8dv6UWGwVak39jwLZzIkfjZU39sWPaI0Vh8lFlQWQys9a6N5vE4IY
	 tEz3WbDp+3TzT2aTaeeNSk5I4NSBktZ6MrFZRprFLd3VYCAbXOr4tLyUYVydeiwaOlts5
	 AKOedOOtNs0t6wrrgyzprrqEGQjMZJz8YfDsL+tDVyOxZnfnbArHgy8EeY1/Ri1jFPbVn
	 cAqBG4FEJawhYdF80G9xiZLu+IPYwnDBEAW7qhDqsfFtZgDo/JoZlWsQLVk9P9ru71A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=secunet.com;
	spf=pass smtp.mailfrom=secunet.com;
	dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=jmnDooWB;
	arc=none smtp.remote-ip=62.96.220.36
X-Received: from mx1.secunet.com (mx1.secunet.com [62.96.220.36])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6770260A2600
	for <netdev@vger.kernel.org>; Mon,  2 Nov 2026 08:04:53 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6770260A2600
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com
X-Received: from localhost (localhost [127.0.0.1])
	by mx1.secunet.com (Postfix) with ESMTP id 444D7207BE;
	Mon,  2 Nov 2026 09:04:52 +0100 (CET)
X-Virus-Scanned: by secunet
X-Received: from mx1.secunet.com ([127.0.0.1])
 by localhost (mx1.secunet.com [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id LKj9Hcg4nadO; Mon,  2 Nov 2026 09:04:51 +0100 (CET)
X-Received: from EXCH-01.secunet.de (rl1.secunet.de [10.32.0.231])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by mx1.secunet.com (Postfix) with ESMTPS id B6728207B0;
	Mon,  2 Nov 2026 09:04:51 +0100 (CET)
X-DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com B6728207B0
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com;
	s=202301; t=1793606691;
	bh=4+A/IPtr1zAGWJVL6F4Lv/Y3Q75zd4cJs2PSxPvnViY=;
	h=From:To:CC:Subject:Date:In-Reply-To:References:From;
	b=jmnDooWBBDcMFGBM43za0DWLcTzq8nT0FI10+e9//+iHJs9SMago5lgYLbrfJ2y/1
	 i3+tKx1oWQ7bKPYWrxWf0NSS2ysmhYJWRMfcar5Q/59ywhgF00SZaloU82AsgC3gMp
	 SRjkTtFWq3Khia9OtgsWyIMmm+vPk2LnGgNiIAFtUeuzlaa6iJvFI0RjtwPN2mLkRz
	 4za4eGuImkvYUhK6/OAxvgG04p6PYLmw54VttLp9t9RWDfGjtHqJfj8Dpfnxf3aoLf
	 Qow+eMIqhSwq28z7/6wowZrhnvIsmi5jGhgCztiSxmy6KFHKbGzxNS+cZ/8fWktnxd
	 3WWSmwNFtJVVQ==
X-Received: from gauss4 (10.182.7.102) by EXCH-01.secunet.de (10.32.0.171) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Mon, 2 Nov
 2026 09:04:50 +0100
X-Received: (nullmailer pid 2505909 invoked by uid 1000);
	Mon, 02 Nov 2026 10:04:58 -0000
X-CC: Herbert Xu <herbert@gondor.apana.org.au>, Steffen Klassert
	<steffen.klassert@secunet.com>, <netdev@vger.kernel.org>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261102100451.2505200-1-steffen.klassert@secunet.com>
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-ClientProxiedBy: EXCH-03.secunet.de (10.32.0.183) To EXCH-01.secunet.de
 (10.32.0.171)