bugGNU GRUB - Bugs: bug #63894, grub_datetime2unixtime() still has...


You are not allowed to post comments on this tracker with your current authentication level.

bug #63894: grub_datetime2unixtime() still has the year 2038 problem.

Submitter:  Masayuki Moriyama <moriyama>
Submitted:  Wed 08 Mar 2023 11:04:29 AM UTC
Category:  Filesystem Severity:  Major
Priority:  5 - Normal Item Group:  Software Error
Status:  None Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Open Release:  Git master
Release:  Reproducibility:  Every Time
Planned Release:  None

Wed 08 Mar 2023 11:04:29 AM UTC, original submission:  

I found two problems in the grub_datetime2unixtime() function.

Problem 1:
The grub_datetime2unixtime() function returns a 64-bit integer unixtime as the second argument, but the variable used for internal calculation is a 32-bit integer variable.

Problem 2:
Year exceeding the unixtime 32-bit integer value is regarded as an error.


 54 static inline int
 55 grub_datetime2unixtime (const struct grub_datetime *datetime, grub_int64_t *nix)
 56 {
 57   grub_int32_t ret; <= Problem 1: 32bit integer
 80   if (datetime->year > 2038 || datetime->year < 1901) <= Problem 2: Year exceeding the unixtime 32-bit integer value is regarded as an error
 81     return 0;
122   *nix = ret; <= Assign 32-bit integer value to 64-bit integer variable
123   return 1;

Due to these problems, the "grub-probe --device DEVICE --target=fs" command cannot recognize the FAT file system if there are directories or files dated after January 19, 2038 in the / directory of the FAT file system.

Steps to Reproduce:

Run on Fedora 36 Workstation Live image.

# fallocate -l 100m fat32.img
# LOOPDEV=$(losetup --show -f fat32.img)
# mkdosfs -F 32 $LOOPDEV
# mkdir -p /mnt/fat32
# mount $LOOPDEV /mnt/fat32
# mkdir /mnt/fat32/EFI
# touch -d "2040-01-01" /mnt/fat32/EFI
# grub2-probe --version
grub2-probe (GRUB) 2.06
# grub2-probe --device $LOOPDEV --target=fs
grub2-probe: error: ../grub-core/kern/fs.c:120:unknown filesystem.

Fedora 37 Workstation Live image does not reproduce any problems because commit e43f3d93b28cce852c110c7a8e40d8311bcd8bb1 (fs/fat: Don't error when mtime is 0) is applied.

Masayuki Moriyama <moriyama>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by moriyama (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-7c56.
    Corresponding source code