public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: david.laight.linux@gmail.com
To: linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org
Cc: Andreas Dilger <adilger.kernel@dilger.ca>,
	"Theodore Ts'o" <tytso@mit.edu>,
	David Laight <david.laight.linux@gmail.com>
Subject: [PATCH 02/44] ext4: Fix saturation of 64bit inode times for old filesystems
Date: Wed, 19 Nov 2025 22:40:58 +0000	[thread overview]
Message-ID: <20251119224140.8616-3-david.laight.linux@gmail.com> (raw)
In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com>

From: David Laight <david.laight.linux@gmail.com>

If an inode only has space for 32bit seconds values the code tries
to saturate the times at the limit of the range (1901..2038).
However the 64bit values is cast to 32bits before the comparisons.

Fix by using clamp() instead of clamp_t(int32_t, ...).

Note that this is unlikely to cause any issues until 2038.

Fixes: 4881c4971df04 ("ext4: Initialize timestamps limits")
Signed-off-by: David Laight <david.laight.linux@gmail.com>
---
 fs/ext4/ext4.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 57087da6c7be..d919cafcb521 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -909,7 +909,7 @@ do {										\
 		(raw_inode)->xtime = cpu_to_le32((ts).tv_sec);			\
 		(raw_inode)->xtime ## _extra = ext4_encode_extra_time(ts);	\
 	} else									\
-		(raw_inode)->xtime = cpu_to_le32(clamp_t(int32_t, (ts).tv_sec, S32_MIN, S32_MAX));	\
+		(raw_inode)->xtime = cpu_to_le32(clamp((ts).tv_sec, S32_MIN, S32_MAX));	\
 } while (0)
 
 #define EXT4_INODE_SET_ATIME(inode, raw_inode)						\
-- 
2.39.5


  reply	other threads:[~2025-11-19 22:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-19 22:40 [PATCH 00/44] Change a lot of min_t() that might mask high bits david.laight.linux
2025-11-19 22:40 ` david.laight.linux [this message]
2025-11-19 22:41 ` [PATCH 30/44] fs: use min() or umin() instead of min_t() david.laight.linux
2025-11-25  9:06   ` Christian Brauner
2026-01-12 21:51   ` Brian Masney
2026-01-13  9:42     ` David Laight
2026-01-13 16:56   ` Mark Brown
2026-01-13 18:33     ` David Laight
2026-01-13 19:10       ` Mark Brown
2026-01-13 19:24       ` David Laight
2025-11-20  1:47 ` [PATCH 00/44] Change a lot of min_t() that might mask high bits Jakub Kicinski
2025-11-20  9:38 ` Lorenzo Stoakes
2025-11-20 14:52 ` (subset) " Jens Axboe
2025-11-24  9:49 ` Herbert Xu

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=20251119224140.8616-3-david.laight.linux@gmail.com \
    --to=david.laight.linux@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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