Skip to content

ext2fs_write_new_inode: large inode extra timestamp not written for inode size 256B #259

Description

@jiajia123-wind

Environment:
32-bit Linux (x86)
Linux kernel: 6.12

Problem:

When creating an ext4 filesystem with inode size 256B (mkfs.ext4 -I 256) and extra_isize enabled, timestamps (atime/mtime/ctime) for large inodes are not correctly written.

Even though large_inode->i_extra_isize is available to store timestamps exceeding 32-bit (including crtime and nanoseconds), ext2fs_write_new_inode() still calls ext2fs_inode_xtime_set() on the caller-provided struct ext2_inode* (128B small inode), which triggers the 32-bit branch and truncates the timestamp.

Reproduction Steps:

# Create 256B inode filesystem with extra_isize
sudo mkfs.ext4 -I 256 /dev/ram0
# Check filesystem features
sudo tune2fs -l /dev/ram0 | grep 'Filesystem features'
# Output should include 'extra_isize'
# Create directory /mnt
sudo mount /dev/ram0 /mnt


root@qemux86:~# stat /mnt/
  File: /mnt/
  Size: 1024            Blocks: 2          IO Block: 1024   directory
Device: 1,0     Inode: 2           Links: 3
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2040-01-01 00:05:59.095000000 +0000
Modify: 2038-01-19 03:14:07.000000000 +0000
Change: 2038-01-19 03:14:07.000000000 +0000
 Birth: 1903-11-25 17:37:31.000000000 +0000

Expected Behavior:

Timestamps (atime/mtime/ctime) for large inodes should correctly store dates beyond 2038, using extra_isize fields.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions