Article View: linux.kernel.netdev
Article #16146Re: [PATCH net-next 06/15] netfilter: xt_time: fix monthday computation for dates past 2039
From: netdev-bot+sashiko
Date: Sat, 14 Nov 2026 03:23
Date: Sat, 14 Nov 2026 03:23
126 lines
12351 bytes
12351 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit "netfilter: xt_time: fix monthday computation for
dates past 2039" fixes a long-standing bug but has no `Fixes:` tag andβ¦
- [Low] Two comments in net/netfilter/xt_time.c no longer match the code
after this patch.
--
netfilter: xt_time: fix monthday computation for dates past 2039
This replaces the days_since_epoch[] table walk in localtime_3() with
time64_to_tm(). With the change, r->monthday stays in the 1-31 range for
dates from 2040-01-01 on. Removing the lookup tables also shrinks the
xt_time object.
> netfilter: xt_time: fix monthday computation for dates past 2039
>
> iocaltime_3() derives the year from days_since_epoch[], which only has
> entries up to 2039. For any date from 2040-01-01 on, the lookup stays on
> the 2039 entry, so the day-of-year offset is 365 or more. That value is
> used to compute r->monthday, which ends up larger than 31 (32 on
> 2040-01-01, and it wraps in the u8 later in the year).
[ ... ]
> Only the real-time clock reaches localtime_3(), so this is not
> triggerable before the clock passes 2040-01-01 UTC.
[Severity: Low]
This isn't a bug, but there's a typo in the first paragraph:
iocaltime_3() should be localtime_3().
Should the first paragraph also say what the out-of-range value leads to?
time_mt() uses it as a shift count:
if (!(info->monthdays_match & (1U << current_time.monthday)))
return false;
On 2040-01-01 monthday is 32. Later in 2040 it wraps in the u8 (for
example, 397 becomes 141). A shift of 32 or more is undefined behaviour,
so UBSAN would report shift-out-of-bounds. Monthday rules would then
match or miss arbitrary days.
Is the "not triggerable before ... 2040-01-01 UTC" statement accurate?
A CAP_SYS_TIME holder can set CLOCK_REALTIME past 2040 today with
settimeofday() or clock_settime(). A bad RTC or NTP source can do the
same.
There is also the XT_TIME_LOCAL_TZ adjustment in time_mt():
if (info->flags & XT_TIME_LOCAL_TZ)
/* Adjust for local timezone */
stamp -= 60 * sys_tz.tz_minuteswest;
kernel/time/time.c limits tz_minuteswest to +/-15*60. East of UTC, the
local stamp can therefore reach 2040 up to 15 hours before UTC does.
The patch also has no Fixes: tag. days_since_epoch[], the
DSE_FIRST = 2039 year walk and the monthday computation all come from
ee4411a1b1e0. Should this carry:
Fixes: ee4411a1b1e0 ("[NETFILTER]: x_tables: add xt_time match")
Cc: stable@vger.kernel.org
That would let stable and long-term kernels that will still run in 2040,
such as CIP SLTS, pick up the fix. Other fixes in the same netfilter
batch carry Fixes: tags, for example "netfilter: flowtable: do not clear
the offload bit twice" and "netfilter: nfnetlink_queue: make skb
writable before writing NFQA_L2HDR".
> diff --git a/net/netfilter/xt_time.c b/net/netfilter/xt_time.c
> index 2065fce8ef81b..f0c4c1d1bc4a0 100644
> --- a/net/netfilter/xt_time.c
> +++ b/net/netfilter/xt_time.c
[ ... ]
> @@ -102,51 +71,12 @@ static inline void localtime_2(struct xtm *r, time64_t time)
>
> static void localtime_3(struct xtm *r, time64_t time)
> {
> - unsigned int year, i, w = r->dse;
> -
> - /*
> - * In each year, a certain number of days-since-the-epoch have passed.
> - * Find the year that is closest to said days.
[ ... ]
> + time64_to_tm(time, 0, &tm);
>
> - r->month = i + 1;
> + r->monthday = tm.tm_mday; /* 1-31 */
> + r->month = tm.tm_mon + 1; /* 1-12 */
> }
[Severity: Low]
The dietlibc-derived tables and table walk are gone now. Does the file
header comment still match the code?
* It is using some modified code from dietlibc (localtime() function)
* that you can find at https://www.fefe.de/dietlibc/
Date conversion now comes from time64_to_tm() in kernel/time/timeconv.c.
The comment in localtime_2() still says it handles monthday:
/*
* Here comes the rest (weekday, monthday). First, divide the SSTE
* by seconds-per-day to get the number of _days_ since the epoch.
*/
But localtime_2() only sets r->dse and r->weekday. That comment was
already inaccurate before this patch. Now localtime_3() doesn't read
r->dse at all, so the mismatch is larger.
Could both comments be updated to match the new code?
--
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113031251.2437074-2-pablo%40netfilter.org
Technical Details
Message-ID:
<179462662444.2199510.8463648532411328010@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363070-linux-kernel-netdev=dewy.ruReferences:
<20261113031251.2437074-7-pablo@netfilter.org>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!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363070-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 06/15] netfilter: xt_time: fix monthday computation for dates past 2039 Date: Sat, 14 Nov 2026 03:23:44 +0000 Organization: Usenet Network Message-ID: <179462662444.2199510.8463648532411328010@kernel.org> References: <20261113031251.2437074-7-pablo@netfilter.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1500360"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:SBHzhanYYflIt9xI4uHxEaBMgv8= sha256:Fc31HOe+UCUpdq6e83bCY0PzEw0uRxMS8KrTxzg7mTU= sha1:0vqHGHozqfwY8RvsxlFPhnbnc/U= sha256:nd2eIwj+RvoQ8o9IoGbj+gAvtaI65DKjoofn3LJoDnI= 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 A1B2C114757; Sat, 14 Nov 2026 06:25:29 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 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, URIBL_BLOCKED=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 qPLFXnckFY1Q; Sat, 14 Nov 2026 06:25:25 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-363070-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 DBDFD114755; Sat, 14 Nov 2026 06:25:16 +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 1781A32A0B; Sat, 14 Nov 2026 03:24:05 +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=1794626626; b=N65zfgM6oeZ8XOhmlyUcJoguz/GvbAHeIOJG3oiUCFIYOes8p82lXmOuRGPva/GD/uqh 7MAxkz5MO+SdJ5HxA3lpLKaO7PtQW1vfNea4Ub4wvpnKkpgSQLIQ1H6X4Sof9N7o2I9Gj 1snK2/1wHrqHKDcwh3MoceXYO83lI8GuhZYbAEqsMZjWkfc2izNMqk73dFcKY5HObGRpv KGL4Q2OsIznHtx1FYHT+grj7bNSzVhAp0oiGqo7PVeMZyawqlXX+fJcojWDCji6Smqx20 9wogGUb6lZnLv3EkEXOhGlZcdABNgHiNwnx2yJzuw1s3XzPquE3xuCxxGQyzoF1prwQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794626626; 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=l/QG+WRhBMZZQ6SOoNj08ao6Y6x1dsfiuoE/yjkwvZY=; b=aT5395jBO1A/np7klbagXLax64TpglXi0xoObnNJ3f1T8UpO06GsCXhijRC3QWVy/L6/ h1+V3AldcswV4LP8zvhujLDQlDaYx0DXFgS1hqMTeu0afAnG+iGDAgWbmYPCTDPmQVKT5 hqNyYRnVqOzxbxtktDS/W+7on1xqe2ds2PCpEbHf6MsxKqvJ8ocyDErourKWl3yD4EWgh XWIMVmLpAOfWl6h4zD4VQAVdax5ddWvYkCvW46mSWBMR/eaovDT/Om9Vft/kVY/aCnkaN wjN0f6rJh8oSzTdHPCmBUMhs1TZ6DkmZHyEvCwBmJBdmGqdVJ/ZTenb/KwdjwZG/oaA== 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=M5vUKbTa; 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 A96A9606A891; Sat, 14 Nov 2026 03:23:46 +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=M5vUKbTa 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=1794626625; b=1JIv6sdJV0TS3t+8wm7vXGAF/MeVyF12Vp9GYiJltA4YHJX8B2hVO6I/TQbnBLfK0daA h7faxjypf61BWmUL970VXzzQZcUx9ABwb2BHZaR82JNdJpJEKHDOqxmr21f/YLDDNi2Bk syXKjE5jz+dnqq//fP9Qu/+qE2asLyb6aLo04wmjgSWSHkvee9wAdZI5IgFKAoMI49WeR 2U9tG2wU/EffqXGXCMol/eYMx+dk9mAdbbh2K/JjWfsfFQqZklfQOn1ex6CfOh8K4mQn3 y1v5reUc5vGujfJtkiBPb4QrEPPyCWv6wGwDsHmsSB4rBKoS4auOAKhz0rxT6aSV7ig== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794626625; 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=l/QG+WRhBMZZQ6SOoNj08ao6Y6x1dsfiuoE/yjkwvZY=; b=C2nEWaw5Fg9sAOLxsZQRVl2+NKLHSiZKlnGaWHSJyKsFH82O3LwlCV98WeXpwLzOdnqm w+dl04ZzhnEhl+XguehnpKK/6pNO/p2GZhC+gEGSF0klPV9f8fzOgY4sa1Qwy6oaW2dxv YW2O8Vhc9fqpZO5X3Jh4GFpp+PLxkelVs+u6s3FsjIqtkRl+m/TQWdUCYAYcfxDRvoHg6 kGDtvjsjCV1TczeQb+T/eHTqkSjIjBcQUtx+C/pbUT0QW9BQLJGVBjJTJQMomh5AePN1W nbPlPerkOMj+02RWIADzjjKyHT3rVkd9fmv4ewTO4wc0x3LT154+HgxAT3XofchR4xw== 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=M5vUKbTa; 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 C92CF606A8A9; Sat, 14 Nov 2026 03:23:45 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DADA71F000C4; Sat, 14 Nov 2026 03:23:44 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794626625; bh=l/QG+WRhBMZZQ6SOoNj08ao6Y6x1dsfiuoE/yjkwvZY=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=M5vUKbTaU5Zz2/sNP7eoYkl7paspBa6JPgw4tlmOFs1KFkwGCi9OXt4FiNfDymXqx pVEmHEmpH4Obz2Naljrk8rqwbmmsPALUUR33YoOcjxPsbImj3FVRxjHzzX2UqW+rFs LLGPGct/RRekswuf4wzbDSdCOcEM3A9ap7vK7PM2TvPUe5SXi/sAhHdyCxaiD+UnLn ocP1V9zdMpRbL3APt3Ebam4XI3EYasRD7r8UPNKhYiESqGvUmRIHglDb0wx4ZglwTh QajwLGHsszqLOSktvVoheNPzVDUtAyCED0xDBvwUhqYP/1Sds2TA0nrfyt23QJLm+1 CoOLKAm3mJioA== X-Cc: netfilter-devel@vger.kernel.org, davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, horms@kernel.org, fw@strlen.de, ja@ssi.bg X-In-Reply-To: <20261113031251.2437074-7-pablo@netfilter.org> X-sashiko-severity: Low 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