summaryrefslogtreecommitdiff
path: root/scripts/basic/split-include.c
diff options
context:
space:
mode:
authorKarl Mehltretter <kmehltretter@gmail.com>2026-09-25 18:57:01 +0200
committerThomas Gleixner <tglx@kernel.org>2026-09-29 21:18:42 +0200
commit2927f7ca78448781e11a4623d347cd653c28adf6 (patch)
treeae3e4e3f406c5e53d77f8fd5c16cbac07cf8ef27 /scripts/basic/split-include.c
parentbc5b66c300b87544e6861b8dff8c45958603cba5 (diff)
downloadlinux-2927f7ca78448781e11a4623d347cd653c28adf6.tar.gz
linux-2927f7ca78448781e11a4623d347cd653c28adf6.zip
time: Prevent time64_to_tm() day truncation on 32-bit
time64_to_tm() accepts a 64-bit seconds value, but stores the quotient in long. On a 32-bit kernel the day count therefore wraps when it reaches 2^31, even though the corresponding year remains representable in struct tm. This is reachable when formatting externally supplied timestamps. For example, NILFS recovery copies the little-endian 64-bit ss_create field from an on-disk segment summary into time64_t. Its sysfs attributes then print that value with %ptTs, whose formatter calls time64_to_tm(). A corrupted image can consequently produce an architecture-dependent printed date. Keep the day quotient in s64 while leaving the seconds-within-day remainder as long. Use div_s64_rem() for the weekday calculation so 32-bit builds do not require compiler runtime division helpers. Fixes: e6c2682a1da3 ("time: Add time64_to_tm()") Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Assisted-by: LLM Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Link: https://patch.msgid.link/20260925165702.51677-2-kmehltretter@gmail.com
Diffstat (limited to 'scripts/basic/split-include.c')
0 files changed, 0 insertions, 0 deletions