[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251119224140.8616-3-david.laight.linux@gmail.com>
Date: Wed, 19 Nov 2025 22:40:58 +0000
From: david.laight.linux@...il.com
To: linux-kernel@...r.kernel.org,
linux-ext4@...r.kernel.org
Cc: Andreas Dilger <adilger.kernel@...ger.ca>,
"Theodore Ts'o" <tytso@....edu>,
David Laight <david.laight.linux@...il.com>
Subject: [PATCH 02/44] ext4: Fix saturation of 64bit inode times for old filesystems
From: David Laight <david.laight.linux@...il.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@...il.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
Powered by blists - more mailing lists