From: netdev-bot+sashiko@kernel.org
To: pablo@netfilter.org
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
Subject: Re: [PATCH net-next 05/13] netfilter: xt_time: fix monthday computation for dates past 2039
Date: Tue, 17 Nov 2026 00:22:48 +0000 [thread overview]
Message-ID: <179487496872.3136.7616374385796675511@kernel.org> (raw)
In-Reply-To: <20261116001612.2806263-6-pablo@netfilter.org>
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 patch fixes a real, user-visible correctness bug: `-m time
--monthdays` rules give wrong results once the clock reaches…
- [Low] The commit message has three inaccuracies, and it understates the
impact.
- [Low] After the patch, some comments and state in
net/netfilter/xt_time.c still describe the removed table-based date…
--
netfilter: xt_time: fix monthday computation for dates past 2039
This patch replaces the days_since_epoch[] table walk in localtime_3()
with time64_to_tm(). This keeps r->monthday and r->month in range for
dates from 2040-01-01 on. The lookup tables and the 2039 limit are
removed, which also shrinks the xt_time object.
> 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: iocaltime_3() should be
localtime_3().
Is the "2040-01-01 UTC" part accurate when XT_TIME_LOCAL_TZ is set?
time_mt() adjusts the stamp before it calls localtime_3():
if (info->flags & XT_TIME_LOCAL_TZ)
/* Adjust for local timezone */
stamp -= 60 * sys_tz.tz_minuteswest;
For timezones east of UTC, tz_minuteswest is negative, so stamp moves
forward. do_sys_settimeofday64() accepts tz_minuteswest down to -15*60.
That means the old code could produce a bad monthday up to 15 hours
before 2040-01-01 UTC.
Could the message also say what the out-of-range monthday leads to?
time_mt() uses it as a shift count:
if (!(info->monthdays_match & (1U << current_time.monthday)))
With the old code, a monthday of 32 or more makes this shift undefined
behaviour, and the rule silently fails to match. Once the u8 wraps back
into 1-31 later in 2040, rules match on the wrong days.
> Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
[Severity: Low]
Should this have a Fixes: tag? The days_since_epoch[] table and
DSE_FIRST = 2039 came in with the original match:
Fixes: ee4411a1b1e0 ("[NETFILTER]: x_tables: add xt_time match")
Without the tag, stable backporters could read this as only the size
cleanup suggested by the bloat-o-meter numbers.
> 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;
> -
[ ... ]
> + 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]
This isn't a bug, but localtime_3() now works only from time and no
longer reads r->dse. Are some comments and struct xtm now out of date?
The file header still credits dietlibc:
* It is using some modified code from dietlibc (localtime() function)
* that you can find at https://www.fefe.de/dietlibc/
The table walk removed here was the last of that code.
The comment in localtime_2() still says it computes monthday:
/*
* Here comes the rest (weekday, monthday). First, divide the SSTE
* by seconds-per-day to get the number of _days_ since the epoch.
*/
It now computes only dse and weekday.
struct xtm also keeps this field:
unsigned int dse;
It used to carry days-since-epoch from localtime_2() to localtime_3().
Now it is only read inside localtime_2(). Could this lead readers to
think localtime_3() depends on localtime_2() running first?
There is also a small side effect. Weekday comes from the unsigned
div_u64() in localtime_2(). Monthday comes from the signed,
floor-corrected division in time64_to_tm(). The two only differ for a
negative stamp. That needs a time within the first day of 1970, plus
either the XT_TIME_CONTIGUOUS one-day subtraction or a timezone west of
UTC.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116001612.2806263-2-pablo%40netfilter.org
next prev parent reply other threads:[~2026-11-17 0:22 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 0:15 [PATCH net-next,v2 00/13] Netfilter updates for net-next Pablo Neira Ayuso
2026-11-16 0:16 ` [PATCH net-next 01/13] netfilter: flowtable: do not hw offload flows in teardown state Pablo Neira Ayuso
2026-11-16 0:23 ` netdev-bot+sinfo
2026-11-16 0:27 ` Pablo Neira Ayuso
2026-11-17 0:22 ` netdev-bot+sashiko
2026-11-16 0:16 ` [PATCH net-next 02/13] netfilter: flowtable: retrieve stats on flow deletion Pablo Neira Ayuso
2026-11-17 0:22 ` netdev-bot+sashiko
2026-11-16 0:16 ` [PATCH net-next 03/13] net: ethernet: mtk_ppe: update " Pablo Neira Ayuso
2026-11-17 0:22 ` netdev-bot+sashiko
2026-11-16 0:16 ` [PATCH net-next 04/13] net: airoha: " Pablo Neira Ayuso
2026-11-17 0:22 ` netdev-bot+sashiko
2026-11-16 0:16 ` [PATCH net-next 05/13] netfilter: xt_time: fix monthday computation for dates past 2039 Pablo Neira Ayuso
2026-11-17 0:22 ` netdev-bot+sashiko [this message]
2026-11-16 0:16 ` [PATCH net-next 06/13] netfilter: nft_flow_offload: do not offload multicast Pablo Neira Ayuso
2026-11-17 0:22 ` netdev-bot+sashiko
2026-11-16 0:16 ` [PATCH net-next 07/13] netfilter: flowtable: purge entries immediately when destroying the flowtable Pablo Neira Ayuso
2026-11-17 0:22 ` netdev-bot+sashiko
2026-11-16 0:16 ` [PATCH net-next 08/13] selftests: netfilter: nf_queue: drop the no-op loop initializer Pablo Neira Ayuso
2026-11-16 0:16 ` [PATCH net-next 09/13] netfilter: flowtable: do not scrub as crossing netns Pablo Neira Ayuso
2026-11-17 0:22 ` netdev-bot+sashiko
2026-11-16 0:16 ` [PATCH net-next 10/13] netfilter: flowtable: tunnel device poisons h_source of fast-path frames Pablo Neira Ayuso
2026-11-16 0:16 ` [PATCH net-next 11/13] netfilter: flowtable: do not clear the offload bit twice Pablo Neira Ayuso
2026-11-16 0:16 ` [PATCH net-next 12/13] netfilter: nfnetlink_queue: make skb writable before writing NFQA_L2HDR Pablo Neira Ayuso
2026-11-16 0:16 ` [PATCH net-next 13/13] selftests: netfilter: add UDP flowtable offload test Pablo Neira Ayuso
2026-11-17 0:22 ` 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=179487496872.3136.7616374385796675511@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=fw@strlen.de \
--cc=horms@kernel.org \
--cc=ja@ssi.bg \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
/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