Bug 2350327 - Segfault during grub2-mkconfig
Summary: Segfault during grub2-mkconfig
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: grub2
Version: 42
Hardware: x86_64
OS: Linux
unspecified
urgent
Target Milestone: ---
Assignee: Nicolas Frayer
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2025-03-06 13:54 UTC by Olivier Keun
Modified: 2025-03-15 00:43 UTC (History)
10 users (show)

Fixed In Version: grub2-2.12-26.fc42
Clone Of:
Environment:
Last Closed: 2025-03-15 00:43:57 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
strace (695.87 KB, application/gzip)
2025-03-06 18:05 UTC, Olivier Keun
no flags Details

Description Olivier Keun 2025-03-06 13:54:01 UTC
Version: grub2-2.12-25.fc42 

Causes a segfault during the config generation:

$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Generating grub configuration file ...
/usr/libexec/os-probes/50mounted-tests: line 186:  5739 Segmentation fault      (core dumped) grub2-mount "$partition" "$tmpmnt" 2> /dev/null
Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
done

Reproducible: Always

Comment 1 Olivier Keun 2025-03-06 14:02:59 UTC
Rollback to grub2-2.12-23.fc42 fixes the issue

Comment 2 Nicolas Frayer 2025-03-06 14:30:19 UTC
Hi Olivier,

Can you please tell us what your disk/partition layout is so we can try to reproduce.
I wasn't able to reproduce but I see you are dual booting with Windows.

Thanks,

Nicolas

Comment 3 Olivier Keun 2025-03-06 14:40:43 UTC
Hi Nicolas,

The layout is as follows:

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
zram0       252:0    0     8G  0 disk [SWAP]
nvme0n1     259:0    0 953,9G  0 disk
├─nvme0n1p1 259:1    0   260M  0 part /boot/efi
├─nvme0n1p2 259:2    0    16M  0 part
├─nvme0n1p3 259:3    0   250G  0 part
├─nvme0n1p4 259:4    0  1000M  0 part
├─nvme0n1p5 259:5    0   260M  0 part
├─nvme0n1p6 259:6    0     1G  0 part /boot
└─nvme0n1p7 259:7    0 701,4G  0 part /home
                                      /

It's a recent installation where these steps were taken:

- Shrink windows partition (from Windows)
- Fedora auto-install into the free space

Please let me know if you need anything else.
Olivier

Comment 4 Leo Sandoval 2025-03-06 17:50:08 UTC
Olivier, 

1. Can you 'strace -f' the grub2-mkconfig call and attach log? 
2. I have scratched built the 2.12-24 version [1], can you give it a try? Version 2.12-25 introduced a fix on ext2 fs, so I would asssume that 2.12-24 also fails..
3. is secure boot enable? mokutil --sb-state? This is relevant because some of the CVE patches changed the behavior when SB is enable

[1] https://koji.fedoraproject.org/koji/taskinfo?taskID=129907167

Comment 5 Olivier Keun 2025-03-06 18:05:51 UTC
Created attachment 2079187 [details]
strace

Comment 6 Olivier Keun 2025-03-06 18:06:54 UTC
(In reply to Leo Sandoval from comment #4)

Yes, secure boot is enabled.

Comment 7 Andre Robatino 2025-03-07 04:20:26 UTC
This also affects F41 (see my comment in https://bodhi.fedoraproject.org/updates/FEDORA-2025-047e844deb ). I'm using an old BIOS machine dual booting Windows 10/Fedora 41. No UEFI.

Comment 8 Andre Robatino 2025-03-07 04:26:45 UTC
And downgrading to 2.12-15.fc41 fixes the problem.

Comment 9 Andre Robatino 2025-03-07 08:45:36 UTC
On my QEMU/KVM Fedora 42 guest with 2.12-25.fc42 (with the above mentioned F41 dual-boot machine as the host), I do NOT experience this problem. But the guest isn't dual boot with Windows, it's Fedora only.

Comment 10 Andre Robatino 2025-03-07 09:18:04 UTC
Info requested from https://bodhi.fedoraproject.org/updates/FEDORA-2025-047e844deb (I got "Error loading preview" when trying to post it there):

lsblk -f:
```
NAME FSTYPE FSVER LABEL                 UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
loop0
     squash 4.0                                                                    0   100% /var/lib/snapd/snap/snapd/23545
loop1
     squash 4.0                                                                    0   100% /var/lib/snapd/snap/core18/2855
loop2
     squash 4.0                                                                    0   100% /var/lib/snapd/snap/bare/5
loop3
     squash 4.0                                                                    0   100% /var/lib/snapd/snap/skype/382
loop4
     squash 4.0                                                                    0   100% /var/lib/snapd/snap/gnome-3-28-1804/198
loop5
     squash 4.0                                                                    0   100% /var/lib/snapd/snap/gtk-common-themes/1535
loop6
     ext4   1.0   /                     12812c2d-ffe7-441a-9090-c083bdba02b3    974G    39% /var/lib/waydroid/rootfs
loop7
     ext4   1.0   vendor                10f59c0c-480e-4680-987d-68bfdc8c5816    974G    39% /var/lib/waydroid/rootfs/vendor
loop8
     squash 4.0                                                                    0   100% /var/lib/snapd/snap/skype/384
loop9
     squash 4.0                                                                    0   100% /var/lib/snapd/snap/snapd/23771
sda                                                                                         
├─sda1
│    ntfs         System Reserved       18C20A8FC20A7174                                    
├─sda2
│    ntfs                               642C22502C221D94                                    
├─sda3
│    ext4   1.0                         622e7ffe-99ce-469a-be48-25b3ec426acd  526.6M    39% /boot
├─sda4
│                                                                                           
└─sda5
     btrfs        fedora_localhost-live 27afeaaf-dec1-4cf6-b501-7080563382bc    974G    39% /var/lib/waydroid/rootfs/vendor/waydroid.prop
                                                                                            /home
                                                                                            /
sr0                                                                                         
zram0
                                                                                            [SWAP]
```

grub2-mkconfig:
```
Generating grub configuration file ...
/usr/libexec/os-probes/50mounted-tests: line 186: 1923985 Segmentation fault      (core dumped) grub2-mount "$partition" "$tmpmnt" 2> /dev/null
/usr/libexec/os-probes/50mounted-tests: line 186: 1924009 Segmentation fault      (core dumped) grub2-mount "$partition" "$tmpmnt" 2> /dev/null
Adding boot menu entry for UEFI Firmware Settings ...
done
```

ls -l /boot:
```
total 356224
-rw-r--r--. 1 root root    279730 Feb 17 19:00 config-6.12.15-200.fc41.x86_64
-rw-r--r--. 1 root root    281770 Feb 21 19:00 config-6.13.4-200.fc41.x86_64
-rw-r--r--. 1 root root    281707 Feb 26 19:00 config-6.13.5-200.fc41.x86_64
drwx------. 4 root root      4096 Jul 18  2024 efi
drwxr-xr-x. 2 root root      4096 Oct 25 01:18 extlinux
drwx------. 5 root root      4096 Mar  6 23:24 grub2
-rw-------. 1 root root 173377946 Oct 25 04:11 initramfs-0-rescue-92a21984faab40da9a2692d800611157.img
-rw-------. 1 root root  30321619 Feb 19 16:11 initramfs-6.12.15-200.fc41.x86_64.img
-rw-------. 1 root root  30152786 Feb 25 17:35 initramfs-6.13.4-200.fc41.x86_64.img
-rw-------. 1 root root  30145541 Feb 27 22:13 initramfs-6.13.5-200.fc41.x86_64.img
drwxr-xr-x. 3 root root      4096 Oct 25 04:08 loader
drwx------. 2 root root     16384 Oct 25 03:59 lost+found
-rw-r--r--. 1 root root    183000 Feb 19 16:11 symvers-6.12.15-200.fc41.x86_64.xz
-rw-r--r--. 1 root root    184444 Feb 25 17:35 symvers-6.13.4-200.fc41.x86_64.xz
-rw-r--r--. 1 root root    184496 Feb 27 22:13 symvers-6.13.5-200.fc41.x86_64.xz
-rw-r--r--. 1 root root  10943980 Feb 17 19:00 System.map-6.12.15-200.fc41.x86_64
-rw-r--r--. 1 root root  11041786 Feb 21 19:00 System.map-6.13.4-200.fc41.x86_64
-rw-r--r--. 1 root root  11043203 Feb 26 19:00 System.map-6.13.5-200.fc41.x86_64
-rwxr-xr-x. 1 root root  16296296 Oct 25 04:10 vmlinuz-0-rescue-92a21984faab40da9a2692d800611157
-rwxr-xr-x. 1 root root  16607592 Feb 17 19:00 vmlinuz-6.12.15-200.fc41.x86_64
-rwxr-xr-x. 1 root root  16685416 Feb 21 19:00 vmlinuz-6.13.4-200.fc41.x86_64
-rwxr-xr-x. 1 root root  16697704 Feb 26 19:00 vmlinuz-6.13.5-200.fc41.x86_64
```

Comment 11 Olivier Keun 2025-03-07 09:48:20 UTC
(In reply to Leo Sandoval from comment #4)
> 2. I have scratched built the 2.12-24 version [1], can you give it a try?
> Version 2.12-25 introduced a fix on ext2 fs, so I would asssume that 2.12-24
> also fails..
> 
> [1] https://koji.fedoraproject.org/koji/taskinfo?taskID=129907167

Tested: the 2.12-24 version in koji also segfaults.

Here is also a more detailed partition layout than the one i posted earlier:

NAME        FSTYPE    FSVER LABEL    UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
zram0       swap      1     zram0    488b58cf-fcdc-4765-aba6-8afaddb890c0                [SWAP]
nvme0n1
├─nvme0n1p1 vfat      FAT32 SYSTEM   1688-A560                             138,7M    46% /boot/efi
├─nvme0n1p2
├─nvme0n1p3 BitLocker 2
├─nvme0n1p4 ntfs            RECOVERY 1CF430BBF430994A
├─nvme0n1p5 vfat      FAT32 MYASUS   0077-CA67
├─nvme0n1p6 ext4      1.0            b9409339-8d23-4f80-b804-e2ecb36d4177  481,9M    44% /boot
└─nvme0n1p7 btrfs           fedora   bb988644-b10e-4c77-9996-3948386c4f29  682,4G     3% /home
                                                                                         /

Comment 12 Marta Lewandowska 2025-03-07 14:12:01 UTC
Thank you for all of that information! We think we know what the culprit might be... if [any of] you could check whether or not these work for you and let us know...
https://people.redhat.com/mlewando/grub2-2.12-20.fc41/
https://people.redhat.com/mlewando/grub2-2.12-26.fc42/

This is not yet a fix, but we want to see if we're going in the right direction. These are scratch builds, which means Secure Boot needs to be disabled / tested on BIOS systems. thank you!

Comment 13 Olivier Keun 2025-03-07 14:24:48 UTC
(In reply to Marta Lewandowska from comment #12)
> Thank you for all of that information! We think we know what the culprit
> might be... if [any of] you could check whether or not these work for you
> and let us know...
> https://people.redhat.com/mlewando/grub2-2.12-20.fc41/
> https://people.redhat.com/mlewando/grub2-2.12-26.fc42/
> 
> This is not yet a fix, but we want to see if we're going in the right
> direction. These are scratch builds, which means Secure Boot needs to be
> disabled / tested on BIOS systems. thank you!

Thanks Marta,

This build works for me on fc42 x64 EFI/secure boot, no segfault.

Comment 14 Marta Lewandowska 2025-03-07 15:31:50 UTC
Thank you for testing Olivier! that is good news ;)

Comment 15 Andre Robatino 2025-03-07 15:36:25 UTC
https://people.redhat.com/mlewando/grub2-2.12-20.fc41/ works for me on F41 x86_64 BIOS, no segfault.

Comment 16 Andre Robatino 2025-03-07 15:50:54 UTC
Also confirmed that the grub.cfg file generated by the above test version is identical to that generated by 2.12-15.fc41.

Comment 17 Marta Lewandowska 2025-03-07 16:39:36 UTC
Great! Thank you, Andre. I'm glad it's working.

Comment 18 Michael Setzer II 2025-03-10 20:15:37 UTC
Just a little add from my issues on Fedora list.

First.
grub2-probe -d /dev/sda1
Segmentation fault (core dumped)
gives the error on the 3 ntfs partitions (regular partitions)
Device     Boot     Start        End    Sectors   Size Id Type
/dev/sda1            2048   39847935   39845888    19G 27 Hidden NTFS WinRE
/dev/sda2  *     39847936   40052735     204800   100M  7 HPFS/NTFS/exFAT
/dev/sda3        40052736  379084799  339032064 161.7G  7 HPFS/NTFS/exFAT
/dev/sda4       379084800 1953523711 1574438912 750.8G  5 Extended
/dev/sda5       714633216  716730367    2097152     1G 83 Linux
/dev/sda6       716732416  724756479    8024064   3.8G 82 Linux swap / Solari 
/dev/sda7       724758528  835887103  111128576    53G 83 Linux
/dev/sda8       835889152 1953523711 1117634560 532.9G 83 Linux
/dev/sda9       379086848  714631167  335544320   160G 83 Linux

To actually create a grubmenu entry for the windows 7.
Then would have option to load windows. Noted that others with windows running via UEFI did make entry.

My notebooks had windows 7 partitions without UEFI
The grub2-config runs, and works, but ends up creating no entries for windows boot, so had to create

scat /etc/grub.d/42_custom
# !/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "Windows 7" {
     insmod ntfs
     set root=(hd0,2)  # Modify this to match your Windows partition
     chainloader +1
 }

Comment 19 Ronald Warsow 2025-03-11 07:20:24 UTC
seeing this aswell

sudo dmesg|grep -i secure
[    0.008226] Secure boot disabled

and

lsblk -f

NAME        FSTYPE FSVER LABEL      UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                                     
├─sda1      vfat   FAT32            0E87-C7D3                                           
├─sda2                                                                                  
├─sda3      ntfs         Win        A0DA9790DA976178                                    
├─sda4      ntfs                    0C1C83031C82E6D4                                    
├─sda5      ntfs         WinData    428838C18838B4EF                                    
└─sda6      btrfs        DEVEL      80ce69a9-95d2-4182-a493-b0a5c7618748   35,8G    17% /home/DATA/DEVEL
zram0                                                                                   [SWAP]
nvme0n1                                                                                 
├─nvme0n1p1 ext4   1.0   BOOT       201bbe92-5de6-4ae9-8801-eea13231b6de  623,9M    29% /boot
├─nvme0n1p2 vfat   FAT32 EFI        1AD8-AD02                            1002,6M     2% /boot/efi
└─nvme0n1p3 btrfs        BTRFS_Pool 704d7d4e-6ca3-4647-b027-44dc162e2b3c  710,5G    14% /home/DATA
                                                                                        /home
                                                                                        /

Comment 20 Fedora Update System 2025-03-11 14:50:43 UTC
FEDORA-2025-22620dca9b (grub2-2.12-26.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2025-22620dca9b

Comment 21 Stephen Morris 2025-03-11 21:40:13 UTC
You've mentioned a fix has been submitted for Fedora 42, is one going to be released for F41?

Just some additional info if it hasn't been looked at already, in my F41 system grub2-mkconfig is producing the segmentation-faults in 50mounted-tests because grub2-mount and grub2-probe both produce a segmentation fault on unmounted ntfs partitions (I'm tri-booting between Fedora, Windows 11 and Ubuntu on a UEFI/Secure Boot system, which because it is UEFI the menu entry for Windows is present because it is being resolved from the EFI partition.

Just possibly off topic here:
I'm not sure that when os-prober runs as part of the grub2-mkconfig process that it is working correctly. For me, when it builds the Ubuntu menu entry it sets it up to boot Ubuntu from /dev/sde1 which is the partition that Ubuntu is installed to, rather than setting up the entry to use the Ubuntu data in the EFI partition like it does for Windows, is that what it is supposed to do (with this setup Ubuntu does boot fine)?

If I run grub2-mkconfig in Ubuntu to build the grub menus, and change my motherboard bios to boot into the Ubuntu grub menus, when I select the Fedora entry I get a shim failure, is this because Fedora is using BTRFS?

Comment 22 Andre Robatino 2025-03-11 21:45:12 UTC
The F41 Bodhi build is at https://bodhi.fedoraproject.org/updates/FEDORA-2025-ecbe75c42b .

Comment 23 Michael Setzer II 2025-03-11 23:21:38 UTC
Glad to see the issue is being looked at, and status shows passed. 
Ran dnf update, but got no new updates yet,and still getting segment fault messages.

On my systems that have Fedora 41 and Windows 7, the regular process results in no boot entries for window without the 42_custom I added.

These machines don't have UEFI or secure boot. Both are older Acer notebooks that original came with Windows 7.
Systems have the original 3 windows partitions, then the Fedora 41 partitions.
Device     Boot     Start        End    Sectors   Size Id Type
/dev/sda1            2048   39847935   39845888    19G 27 Hidden NTFS WinRE
/dev/sda2  *     39847936   40052735     204800   100M  7 HPFS/NTFS/exFAT
/dev/sda3        40052736  379084799  339032064 161.7G  7 HPFS/NTFS/exFAT
/dev/sda4       379084800 1953523711 1574438912 750.8G  5 Extended
/dev/sda5       714633216  716730367    2097152     1G 83 Linux
/dev/sda6       716732416  724756479    8024064   3.8G 82 Linux swap / Solaris
/dev/sda7       724758528  835887103  111128576    53G 83 Linux
/dev/sda8       835889152 1953523711 1117634560 532.9G 83 Linux
/dev/sda9       379086848  714631167  335544320   160G 83 Linux

Partition table entries are not in disk order.
# for a in $(sfdisk -l | cut -b6-9 |grep sda) ; do echo -n $a" "; grub2-probe -d /dev/$a ; done 
sda1 Segmentation fault (core dumped)
sda2 Segmentation fault (core dumped)
sda3 Segmentation fault (core dumped)
sda4 grub2-probe: error: cannot find a GRUB drive for /dev/sda4.  Check your device.map.
sda5 ext2
sda6 grub2-probe: error: ../grub-core/kern/fs.c:123:unknown filesystem.
sda7 ext2
sda8 ext2
sda9 ext2

So, grub2-probe has issues with partitions 1-4 and 6.
Would expect issues with Extended partition, but not clear on others.

Hopefully, full solution will be released shortly.

Comment 24 Fedora Update System 2025-03-12 01:45:20 UTC
FEDORA-2025-22620dca9b has been pushed to the Fedora 42 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2025-22620dca9b`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2025-22620dca9b

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 25 Michael Setzer II 2025-03-12 05:56:47 UTC
Just did test.
dnf upgrade --enablerepo=updates-testing grub2*

No more segment fault
grub2-probe -d /dev/sda2
ntfs

and 
grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found Windows 7 on /dev/sda2
Adding boot menu entry for UEFI Firmware Settings ...
done

So, seems the issue might be fixed soon.

Comment 26 Ronald Warsow 2025-03-12 14:35:06 UTC
fixed with comment #22

Thanks for lightning fast support !!!

Comment 27 Fedora Update System 2025-03-15 00:43:57 UTC
FEDORA-2025-22620dca9b (grub2-2.12-26.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.