Bug 912873

Summary: grubby --default-kernel segfaults on ARM uboot system
Product: [Fedora] Fedora Reporter: Evan McNabb <emcnabb>
Component: grubbyAssignee: Peter Jones <pjones>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 18CC: bcl, blc, bpeck, dmarlin, jbastian, pjones
Target Milestone: ---   
Target Release: ---   
Hardware: arm   
OS: Unspecified   
Whiteboard:
Fixed In Version: grubby-8.25-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-02-05 23:19:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Simple patch to error out instead of segfaulting none

Description Evan McNabb 2013-02-19 21:48:12 UTC
Description of problem:

Calling grubby with --default-kernel results in a segfault on a Calxada Highbank (ARM) system. This system uses uboot.

# grubby --default-kernel
grubby received SIGSEGV!  Backtrace (0):

# strace grubby --default-kernel
...
open("/etc/popt", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
stat64("/etc/popt.d", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
openat(AT_FDCWD, "/etc/popt.d", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
fcntl64(3, F_GETFD)                     = 0x1 (flags FD_CLOEXEC)
getdents64(3, /* 2 entries */, 32768)   = 48
getdents64(3, /* 0 entries */, 32768)   = 0
close(3)                                = 0
open("/root/.popt", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
access("/etc/grub2-efi.cfg", R_OK)      = -1 ENOENT (No such file or directory)
access("/etc/grub2.cfg", R_OK)          = -1 ENOENT (No such file or directory)
access("/etc/grub.d/", R_OK)            = -1 ENOENT (No such file or directory)
access("/boot/grub/menu.lst", R_OK)     = -1 ENOENT (No such file or directory)
access("/etc/grub.conf", R_OK)          = -1 ENOENT (No such file or directory)
stat64("/", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
stat64("/boot", {st_mode=S_IFDIR|0555, st_size=1024, ...}) = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0} ---
rt_sigaction(SIGSEGV, {SIG_DFL, [SEGV], SA_RESTART|0x4000000}, {0xc9a8, [SEGV], SA_RESTART|0x4000000}, 8) = 0
write(2, "grubby received SIGSEGV!  Backtr"..., 41grubby received SIGSEGV!  Backtrace (0):
) = 41
exit_group(1)                           = ?
+++ exited with 1 +++
#

(gdb) run --default-kernel
Starting program: /usr/sbin/grubby --default-kernel

Program received signal SIGSEGV, Segmentation fault.
main (argc=0, argv=0xbeffede0) at grubby.c:4144
4144	    config = readConfig(grubConfig, cfi);
Missing separate debuginfos, use: debuginfo-install libblkid-2.22.2-3.fc18.armv7hl libgcc-4.7.2-8.fc18.armv7hl libuuid-2.22.2-3.fc18.armv7hl
(gdb) bt
#0  main (argc=0, argv=0xbeffede0) at grubby.c:4144
(gdb) 

Version-Release number of selected component (if applicable):
grubby-8.22-1.fc18.armv7hl

How reproducible:
Every time.

Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 D. Marlin 2013-02-20 22:09:09 UTC
Currently, ARM-based systems use the U-Boot bootloader, and not one of the bootloaders supported by grubby (GRUB, lilo, elilo, yaboot or zipl).  While the new-kernel-pkg script has been modified to install U-Boot kernel images, the grubby tool is not U-Boot aware, so while I agree it should not segfault, it will not be able to return the default kernel, or probably any other information typically stored in the supported bootloader configuration files.

Perhaps grubby could be modified to check for one of the supported bootloader configuration files when run, and exit with an "Unsupported" message if none are found.  This would avoid issues on ARM systems using U-Boot, or any other unsupported bootloaders it might encounter in the future.

Comment 2 Evan McNabb 2013-02-21 14:52:25 UTC
(In reply to comment #1)
> Perhaps grubby could be modified to check for one of the supported
> bootloader configuration files when run, and exit with an "Unsupported"
> message if none are found.  This would avoid issues on ARM systems using
> U-Boot, or any other unsupported bootloaders it might encounter in the
> future.

I agree with this approach.

Comment 3 Brendan Conoboy 2013-03-06 04:05:30 UTC
The problem is line 4144:
    config = readConfig(grubConfig, cfi);

'grubConfig' is null.

Evidence:
(gdb) break 4143
Breakpoint 1 at 0xa744: file grubby.c, line 4143.
(gdb) run --default-kernel
Starting program: /usr/sbin/grubby --default-kernel

Breakpoint 1, main (argc=0, argv=0xbefff110) at grubby.c:4144
4144	    config = readConfig(grubConfig, cfi);
(gdb) step
readConfig (cfi=0x0, inName=0x0) at grubby.c:956
956	    if (!strcmp(inName, "-")) {
(gdb) step

Program received signal SIGSEGV, Segmentation fault.

Seems like a trivial fix unless there is a sane thing to be done in the absence of a grubConfig.

Comment 4 Brendan Conoboy 2013-03-06 04:47:40 UTC
Created attachment 705760 [details]
Simple patch to error out instead of segfaulting

Comment 5 Peter Jones 2013-04-09 15:36:20 UTC
This is fixed in grubby-8.25-1

Comment 6 Fedora End Of Life 2013-12-21 15:44:42 UTC
This message is a reminder that Fedora 18 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 18. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '18'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 18's end of life.

Thank you for reporting this issue and we are sorry that we may not be 
able to fix it before Fedora 18 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior to Fedora 18's end of life.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 7 Fedora End Of Life 2014-02-05 23:19:45 UTC
Fedora 18 changed to end-of-life (EOL) status on 2014-01-14. Fedora 18 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.