From: netdev-bot+sashiko@kernel.org
To: steffen.klassert@secunet.com
Cc: davem@davemloft.net, kuba@kernel.org,
herbert@gondor.apana.org.au, netdev@vger.kernel.org
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 [thread overview]
Message-ID: <179369310395.488856.1196610792291916744@kernel.org> (raw)
In-Reply-To: <20261102100451.2505200-8-steffen.klassert@secunet.com>
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
next prev parent reply other threads:[~2026-11-03 8:05 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 10:03 [PATCH 0/14] pull request (net): ipsec 2026-11-02 Steffen Klassert
2026-11-02 10:03 ` [PATCH 01/14] xfrm: retry inexact policy lookup after node reinsertion Steffen Klassert
2026-11-02 8:09 ` netdev-bot+sinfo
2026-11-03 12:30 ` patchwork-bot+netdevbpf
2026-11-02 10:04 ` [PATCH 02/14] xfrm: interface: validate the IP header on xmit Steffen Klassert
2026-11-03 8:05 ` netdev-bot+sashiko
2026-11-03 9:34 ` Steffen Klassert
2026-11-02 10:04 ` [PATCH 03/14] xfrm: zero-initialise km_event in the replay-notify path Steffen Klassert
2026-11-02 10:04 ` [PATCH 04/14] xfrm: espintcp: reorder operations within espintcp_init_sk Steffen Klassert
2026-11-03 8:05 ` netdev-bot+sashiko
2026-11-02 10:04 ` [PATCH 05/14] xfrm: state: reject mark with bits outside its mask on add Steffen Klassert
2026-11-03 8:05 ` netdev-bot+sashiko
2026-11-02 10:04 ` [PATCH 06/14] xfrm: state: reject mark with bits outside its mask on ALLOCSPI Steffen Klassert
2026-11-03 8:05 ` netdev-bot+sashiko
2026-11-02 10:04 ` [PATCH 07/14] xfrm: policy: reject mark with bits outside its mask on add Steffen Klassert
2026-11-03 8:05 ` netdev-bot+sashiko [this message]
2026-11-03 9:37 ` Steffen Klassert
2026-11-02 10:04 ` [PATCH 08/14] xfrm: state: exact mark/mask match for SPI-keyed control-plane SA lookups Steffen Klassert
2026-11-03 8:05 ` netdev-bot+sashiko
2026-11-03 10:17 ` Steffen Klassert
2026-11-02 10:04 ` [PATCH 09/14] xfrm: fix use-after-free of migrated state in xfrm_do_migrate_state() Steffen Klassert
2026-11-02 10:04 ` [PATCH 10/14] xfrm: fix hw offload state leak on xfrm_do_migrate_state() error path Steffen Klassert
2026-11-02 10:04 ` [PATCH 11/14] xfrm: include mark in MIGRATE_STATE SA collision check Steffen Klassert
2026-11-03 8:05 ` netdev-bot+sashiko
2026-11-03 11:13 ` Steffen Klassert
2026-11-03 12:17 ` Paolo Abeni
2026-11-02 10:04 ` [PATCH 12/14] xfrm: pass extack through to xfrm_init_replay() from xfrm_init_state() Steffen Klassert
2026-11-02 10:04 ` [PATCH 13/14] docs: xfrm: include mark in XFRM_MSG_MIGRATE_STATE EEXIST tuple Steffen Klassert
2026-11-03 8:05 ` netdev-bot+sashiko
2026-11-02 10:04 ` [PATCH 14/14] xfrm4: use a full socket for local errors Steffen Klassert
2026-11-03 8:05 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179369310395.488856.1196610792291916744@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox