URL: <https://savannah.gnu.org/bugs/?63894>
Summary: grub_datetime2unixtime() still has the year 2038 problem. Group: GNU GRUB Submitter: 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: Originator Email: Open/Closed: Open Release: Git master Release: Discussion Lock: Any Reproducibility: Every Time Planned Release: None _______________________________________________________ Follow-up Comments: ------------------------------------------------------- Date: Wed 08 Mar 2023 11:04:29 AM UTC By: Masayuki Moriyama <moriyama> 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. include/grub/datetime.h <https://git.savannah.gnu.org/cgit/grub.git/tree/include/grub/datetime.h?id=88478417315b652850e36ff7f3f63f6bcf399e84>: 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 ...snip... 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; ...snip... 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 <https://ftp.riken.jp/Linux/fedora/releases/36/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-36-1.5.iso>. # 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 <https://download.fedoraproject.org/pub/fedora/linux/releases/37/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-37-1.7.iso> does not reproduce any problems because commit e43f3d93b28cce852c110c7a8e40d8311bcd8bb1 <https://git.savannah.gnu.org/cgit/grub.git/commit/grub-core/fs?id=e43f3d93b28cce852c110c7a8e40d8311bcd8bb1> (fs/fat: Don't error when mtime is 0) is applied. _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?63894> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/