linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: fix decoding of raw_inode timestamps
@ 2023-07-12 15:02 Jeff Layton
  2023-07-12 15:32 ` Christian Brauner
  2023-07-12 17:52 ` Theodore Ts'o
  0 siblings, 2 replies; 8+ messages in thread
From: Jeff Layton @ 2023-07-12 15:02 UTC (permalink / raw)
  To: brauner, Theodore Ts'o, Andreas Dilger, Jan Kara
  Cc: linux-fsdevel, linux-ext4, linux-kernel

When we covert a timestamp from raw disk format, we need to consider it
to be signed, as the value may represent a date earlier than 1970. This
fixes generic/258 on ext4.

Cc: Jan Kara <jack@suse.cz>
Fixes: f2ddb05870fb ("ext4: convert to ctime accessor functions")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ext4/ext4.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

It might be best to just squash this fix in with the ext4 conversion in
the vfs tree.

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index d63543187359..2af347669db7 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -877,7 +877,7 @@ static inline __le32 ext4_encode_extra_time(struct timespec64 ts)
 static inline struct timespec64 ext4_decode_extra_time(__le32 base,
 						       __le32 extra)
 {
-	struct timespec64 ts = { .tv_sec = le32_to_cpu(base) };
+	struct timespec64 ts = { .tv_sec = (signed)le32_to_cpu(base) };
 
 	if (unlikely(extra & cpu_to_le32(EXT4_EPOCH_MASK)))
 		ts.tv_sec += (u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) << 32;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-13 13:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-12 15:02 [PATCH] ext4: fix decoding of raw_inode timestamps Jeff Layton
2023-07-12 15:32 ` Christian Brauner
2023-07-12 17:52 ` Theodore Ts'o
2023-07-12 18:09   ` Jeff Layton
2023-07-12 21:25     ` Theodore Ts'o
2023-07-13 10:48       ` Jeff Layton
2023-07-13 13:04         ` Theodore Ts'o
2023-07-13 13:19           ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).