Article View: linux.kernel.netdev
Article #16772Re: [PATCH ipsec] xfrm: avoid wrapping AEVENT timer thresholds
From: netdev-bot+sashiko
Date: Sun, 15 Nov 2026 20:32
Date: Sun, 15 Nov 2026 20:32
104 lines
11570 bytes
11570 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] The patch clamps x->replay_maxage only on the sysctl path.
--
xfrm: avoid wrapping AEVENT timer thresholds
This patch converts net->xfrm.sysctl_aevent_etime to jiffies in u64 and
clamps the result to min(U32_MAX, MAX_JIFFY_OFFSET) before storing it in
x->replay_maxage. It also widens the arithmetic build_aevent() uses when
it reports XFRMA_ETIMER_THRESH, so large stored values do not wrap on
readback.
> diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
> index f802899d3d130..d7fa63aeea37b 100644
> --- a/net/xfrm/xfrm_user.c
> +++ b/net/xfrm/xfrm_user.c
> @@ -924,6 +924,14 @@ static void xfrm_smark_init(struct nlattr **attrs, struct xfrm_mark *m)
> }
> }
>
> +static u32 xfrm_aevent_etime_to_jiffies(u32 etime)
> +{
> + u64 maxage = min_t(u64, U32_MAX, MAX_JIFFY_OFFSET);
> + u64 j = div_u64((u64)etime * HZ, XFRM_AE_ETH_M);
> +
> + return min_t(u64, j, maxage);
> +}
> +
> static struct xfrm_state *xfrm_state_construct(struct net *net,
> struct xfrm_usersa_info *p,
> struct nlattr **attrs,
> @@ -1022,7 +1030,8 @@ static struct xfrm_state *xfrm_state_construct(struct net *net,
> x->km.seq = p->seq;
> x->replay_maxdiff = net->xfrm.sysctl_aevent_rseqth;
> /* sysctl_xfrm_aevent_etime is in 100ms units */
> - x->replay_maxage = (net->xfrm.sysctl_aevent_etime*HZ)/XFRM_AE_ETH_M;
> + x->replay_maxage =
> + xfrm_aevent_etime_to_jiffies(net->xfrm.sysctl_aevent_etime);
[Severity: Medium]
The commit message says the value is clamped to the range "safe for
jiffies comparisons". This clamp only applies to the sysctl default,
though.
A little further down, xfrm_state_construct() calls
xfrm_update_ae_params(x, attrs, 0). That call overwrites replay_maxage
with the raw attribute value whenever XFRMA_ETIMER_THRESH is present:
net/xfrm/xfrm_user.c:xfrm_update_ae_params() {
...
if (et)
x->replay_maxage = nla_get_u32(et);
...
}
xfrm_new_ae() reaches the same store on a live SA through
xfrm_update_ae_params(x, attrs, 1). The xfrma_policy entry for
XFRMA_ETIMER_THRESH is only NLA_U32, so it does no range check.
On 32-bit kernels, MAX_JIFFY_OFFSET is 0x3FFFFFFE. If a caller sends
XFRMA_ETIMER_THRESH >= 0x80000000, this call gives the timer a negative
delta:
mod_timer(&x->rtimer, jiffies + x->replay_maxage);
The call appears in __xfrm_state_insert(), xfrm_replay_notify(),
xfrm_replay_notify_bmp() and xfrm_replay_notify_esn().
calc_wheel_index() treats a negative delta as already expired:
} else if ((long) delta < 0) {
idx = clk & LVL_MASK;
*bucket_expiry = clk;
Would rtimer then fire on the next tick? If so, XFRM_MSG_NEWAE
notifications would no longer be rate-limited while the replay state
keeps changing.
This looks like the "turning a long threshold into a short delay" case
the commit message describes. It can still be reached through netlink
with CAP_NET_ADMIN in the netns, including from a user namespace.
Should xfrm_update_ae_params() apply the same clamp, or should the
XFRMA_ETIMER_THRESH policy carry a matching range?
>
> if ((err = xfrm_init_replay(x, extack)))
> goto error;
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261114091239.780633-1-flashhhhha%40gmail.com
Technical Details
Message-ID:
<179477476677.3136.11263726270247439987@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363848-linux-kernel-netdev=dewy.ruReferences:
<20261114091239.780633-1-flashhhhha@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363848-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH ipsec] xfrm: avoid wrapping AEVENT timer thresholds Date: Sun, 15 Nov 2026 20:32:46 +0000 Organization: Usenet Network Message-ID: <179477476677.3136.11263726270247439987@kernel.org> References: <20261114091239.780633-1-flashhhhha@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1893744"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:LElISun+69qWDmPiVyC5PIKCVAs= sha256:wK7la8AvVHN3wfKNSTvZ1B/hmcBv6yjeYqtTC4e7SeM= sha1:x+HgBCfFBLMQDCTCMX58Z69m5i4= sha256:E2+ndNzG5YnStfiqqJ0fjsdfIFQufpfOPH7HTdiuL5U= 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 5F85D114A4C; Sun, 15 Nov 2026 23:33:11 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[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 YtjvR5kn_0Kg; Sun, 15 Nov 2026 23:33:01 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-363848-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 7BA34114A5B; Sun, 15 Nov 2026 23:32:52 +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 755AC6029C4; Sun, 15 Nov 2026 20:32:50 +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=1794774769; b=z2+ZYypjrPvgZqJUxksGlhiIRLkzN3u9ydSNZUHfU+heLd/e4EhNDCHdlFPVdEFarjog XFQJjm9YfRFFWsXtB1OBeUXAU4F4rExD1ESd5KBaIEagyaYiFsWE/abRi6VTHJpehh9k/ HlnM7ewft/Ku2FQ8YoDbvNQcy279MkoPFIDKgv9BrNBI3ImNcSN86O6i29w5O7dJt+GPF +3CiYc2cVHV1iaJJSC30aCCBL/g1L3vScPa7sQE54hu/G1IX8ejl4zIXwmRhOgfEDx1xp 3ZIQ5qj3NO+s8X56MPelqup2TCc/b4jr5CM0CHkLXI8rThBHVXWIS5PXBZ2O8DFGpuA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794774769; 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=z2E8cye9N7jDa4iULpcVRKN56VXJv3+yGHq6G/gPctE=; b=kB7iAdeb44RIQpetXoP+m/r+PD6QcYKgl21TEmSgd6mrxFEi+eEyJ4IqlFGF5gpfOXxM aAD1RNwCyBI4Y5L+QK467MNtqBGh5sD4YXVZkb0JZzgHZ06U2HE8FieHTD9Df9od/HXvm xDprVdglb3W9fQYjJpbTWtc5iK2gnDq+G6iVm21EfKF8Z2kmpiO1urAKhcCU2QlKgCMLq OMFcL93kb3WKrs7G8XfP+zfZNVSxO7sRh8Li10BLZ1PI8t79pVMYz4JAXKWnLUeNma9wj ZSiHI7nJ+EEy0h9yLrFWX53k+TLu+IXIjHnQJCIdrKDQ6xZE1aof4ZAJAbc5gUPex8w== 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=XXjEXxGs; 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 EC717606A338; Sun, 15 Nov 2026 20:32:48 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XXjEXxGs 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=1794774768; b=BsfOYL2Km9A0aHb9gcDVR/W76QsZ8i3GGEf0hCZSRzqnmKSU5kUZo+QH9G4wZArHuj4P FNvLqNrWMpioMX/qaIPSzYQZHIlU1GLUJhPzLe9aSIpyH+hUwva4PxN9dCUlV9u1wOdVH DyophAr0hvBZZfvnIee+EtrBNw2ApcLEazLwMxE8/cs9OVx82GJpHMaJbMHId3LyIfsN8 MXzHo6YqkPd0jJOk83Sib1t8BWdWl3K58nW+VHdOyr9GQ4ro+1HI/I+Oz7W0N5KPJN6Sf 3dVx9EcufmhLujrLOHLIuHztuAZoTB88KXUJfUVyG6qchqaxNHNgqwl9SjX1RZgqNaQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794774768; 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=z2E8cye9N7jDa4iULpcVRKN56VXJv3+yGHq6G/gPctE=; b=eiekEFpsX42kquWRDUlxeM18FkNDnOl9XIiRIvImTP+pSB2D/HWCjbYvGfX2EwWJEUlv Q39jRCHo+2w4ezhYvQoGVucZxqMnC8aTQBHCDmZZ60c0JJKyuheTa6z/FOcsaYwbXZZlk dhunPPxvXTIDNNrubm1zljF3i7Hbf7ZjkGjFWXl4eBSouPf6QpTdZwg9XIzYkx15u3vEO qz6IgVzrJSmfqKqppbT3zwZcWPxPXl9x6MqD5u+whs80Y4fYfNmlA3bgKaJgT+nSrK4BN dheB9TFVFlzdOXOV+2o6Wnh4fNeaJssh8kQgirTjAX6/rGDfTnRnl9qtcOhCgN+YehQ== 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=XXjEXxGs; 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 141D6606A31F; Sun, 15 Nov 2026 20:32:48 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E4BF1F000C4; Sun, 15 Nov 2026 20:32:47 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794774767; bh=z2E8cye9N7jDa4iULpcVRKN56VXJv3+yGHq6G/gPctE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=XXjEXxGsZhFdiIdgAd9zdQZ5sg2zi9bU9wCcqLMbLpM0K30o2aQN6JSwgfIj7Aima UFwVvHruhejgF6ZccneCpLn9aoeV6eZoj/eLW3R+LzWeXoDdgNGbDuLEQnLxlPhsK7 mfFgdWvShzoZaqHjBKdGQV0IR96LRF37IKjvVT4Au4gurr6hcDFV1kxOIDlOgC8Mqa uC6YdDM28Mi6nhMJX9zR3wKxYzCick+pbb7Zk28IFOk20ucBk2YzX2rm8/FAMhd/lX 9Ti3pvxcE/S3wru1A2wG41hMRq8nMcF7A9jVC4ZyDo1F08OOfbav9TYkj3usOGI/gR lAiXr0naZ6nqg== X-Cc: steffen.klassert@secunet.com, herbert@gondor.apana.org.au, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, jhs@mojatatu.com, netdev@vger.kernel.org, ipsec@lists.linux.dev, linux-kernel@vger.kernel.org, stable@vger.kernel.org X-In-Reply-To: <20261114091239.780633-1-flashhhhha@gmail.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