Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 622716 - >=sys-kernel/genkernel-3.5.1.0: Kernel not initializes: "invalid magic number"
Summary: >=sys-kernel/genkernel-3.5.1.0: Kernel not initializes: "invalid magic number"
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords: PMASKED
Depends on:
Blocks:
 
Reported: 2017-06-25 21:36 UTC by Gabriel D'Ambrosio
Modified: 2017-07-15 04:34 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
kernel-config-x86_64-4.11.0-pf6 (kernel-config-x86_64-4.11.0-pf6,116.17 KB, text/plain)
2017-06-28 14:21 UTC, Joonas Niilola
Details
kernel-config-x86_64-4.11.7-gentoo (file_622716.txt,158.64 KB, text/plain)
2017-06-28 14:29 UTC, Anna Tikhomirova
Details
kernel-config-x86_64-4.11.7-gentoo (kernel-config-x86_64-4.11.7-gentoo,153.11 KB, text/plain)
2017-06-28 16:49 UTC, Gabriel D'Ambrosio
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabriel D'Ambrosio 2017-06-25 21:36:35 UTC
I updated genkernel to last version: 3.5.1.0 and recompiled my kernel-4.11.7. After reboot, kernel not load and show this message: "invalid magic number".

I did downgrade genkernel to 3.5.0.8 and everything worked again.

----

# emerge --info sys-kernel/genkernel
Portage 2.3.6 (python 3.5.3-final-0, default/linux/amd64/13.0/desktop/plasma, gcc-6.3.0, glibc-2.24-r3, 4.11.7-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.11.7-gentoo-x86_64-Intel-R-_Core-TM-_i3-2100_CPU_@_3.10GHz-with-gentoo-2.4.1
KiB Mem:     8039816 total,   6175720 free
KiB Swap:    1048572 total,   1048572 free
Timestamp of repository gentoo: Sun, 25 Jun 2017 01:00:01 +0000
sh bash 4.4_p12
ld GNU ld (Gentoo 2.28 p1.2) 2.28
app-shells/bash:          4.4_p12::gentoo
dev-java/java-config:     2.2.0-r3::gentoo
dev-lang/perl:            5.24.1-r2::gentoo
dev-lang/python:          2.7.13::gentoo, 3.5.3::gentoo
dev-util/cmake:           3.8.2::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.4.1::gentoo
sys-apps/openrc:          0.27.2::gentoo
sys-apps/sandbox:         2.10-r4::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r3::gentoo
sys-devel/automake:       1.13.4-r1::gentoo, 1.15.1::gentoo
sys-devel/binutils:       2.28-r2::gentoo
sys-devel/gcc:            6.3.0::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r4::gentoo
sys-devel/make:           4.2.1-r1::gentoo
sys-kernel/linux-headers: 4.10::gentoo (virtual/os-headers)
sys-libs/glibc:           2.24-r3::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /usr/bin/startx"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs collision-protect config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync network-sandbox news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="ftp://gentoo.c3sl.ufpr.br/gentoo/ http://gentoo.c3sl.ufpr.br/ rsync://gentoo.c3sl.ufpr.br/gentoo/"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac acl acpi alsa alsa-plugins amd64 berkdb branding bzip2 cairo cdda cdr cli consolekit cracklib crypt cryptsetup cups cxx d3d9 dbus declarative device-mapper dri dri3 dts dvd dvdr emboss encode exif fam firefox flac fortran gdbm gif glamor gtk gtk3 iconv icu introspection ipv6 javafx jpeg kde kdeo kipi kwallet lcms ldap libnotify mad mng modules mp3 mp4 mpeg multilib ncurses networkmanager nls nptl nss ogg opengl openmp pam pango pcre pdf phonon plasma png policykit ppds pulseaudio python qml qt3support qt4 qt5 readline sdl seccomp secure-delete semantic-desktop session spell sqlite ssl startup-notification svg tcpd threads tiff truetype udev udisks unicode upower usb vorbis widgets wxwidgets x264 x265 xattr xcb xcomposite xinerama xml xscreensaver xv xvid zlib" ABI_X86="32 64" ALSA_CARDS="hda-intel" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="evdev mouse keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" PYTHON_SINGLE_TARGET="python3_5" PYTHON_TARGETS="python2_7 python3_5" RUBY_TARGETS="ruby23 ruby24" USERLAND="GNU" VIDEO_CARDS="intel i965" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
USE_PYTHON="2.7 3.5"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

sys-kernel/genkernel-3.5.0.8::gentoo was built with the following:
USE="cryptsetup firmware (-ibm) (-selinux)" ABI_X86="(64)"

If need more information, please request.
Comment 1 Wes 2017-06-26 02:51:49 UTC
I've hit this one as well.  I found the kernel it's producing is an EFI PE32+ executable.  I wonder if this is because it's parsing EFI_STUB from the kernel config.  To workaround I manually copied arch/x86/boot/bzImage from the built kernel sources over the top of the resulting kernel in /boot
Comment 2 Wes 2017-06-26 03:04:22 UTC
(In reply to Wes from comment #1)
> I've hit this one as well.  I found the kernel it's producing is an EFI
> PE32+ executable.  I wonder if this is because it's parsing EFI_STUB from
> the kernel config.  To workaround I manually copied arch/x86/boot/bzImage
> from the built kernel sources over the top of the resulting kernel in /boot

Side note and slightly off topic for this bug report, but there appears to be more wrong with this version of genkernel than just this.  After rebooting to the bzImage+initrd, I've discovered it neglected to include mdadm modules in the initrd (required for this system's boot) despite being told to in config and commandline.  3.5.1.0 isn't ready
Comment 3 Anna Tikhomirova 2017-06-27 12:56:21 UTC
I have the same issue.

This is caused by genkernel because the original bzImage is fine:

# file /usr/src/linux/arch/x86/boot/bzImage 
/usr/src/linux/arch/x86/boot/bzImage: Linux kernel x86 boot executable bzImage, version 4.11.7-gentoo (root@localhost) #1 SMP Tue Jun 27 15:46:22 MSK 2017, RO-rootFS, swap_dev 0x3, Normal VGA
# file /boot/kernel-genkernel-x86_64-4.11.7-gentoo 
/boot/kernel-genkernel-x86_64-4.11.7-gentoo: PE32+ executable (EFI application) x86-64 (stripped to external PDB), for MS Windows+

It seems that this commit broke the things:

https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=c2525c65b9f3d5849963bab6beb40817d7720218
Comment 4 Anna Tikhomirova 2017-06-27 13:44:45 UTC
It seems that patch in bug #209387 does something wrong and should be rolled back and revised.
Comment 5 Anna Tikhomirova 2017-06-27 13:51:43 UTC
(In reply to Wes from comment #2)
> 
> Side note and slightly off topic for this bug report, but there appears to
> be more wrong with this version of genkernel than just this.  After
> rebooting to the bzImage+initrd, I've discovered it neglected to include
> mdadm modules in the initrd (required for this system's boot) despite being
> told to in config and commandline.  3.5.1.0 isn't ready

The same issue. Adding --no-strip fixed the broken bzImage, but there is also something wrong with initramfs too. It does not load scsi drivers, resulting in "Could not find the root block device".

I think someone should open a separate bug report for this.
Comment 6 Ivan Iraci 2017-06-28 08:25:26 UTC
Genkernel 3.5.1.0 breaks booting from raid arrays.
Comment 7 Thomas Deutschmann (RETIRED) gentoo-dev 2017-06-28 13:46:25 UTC
Can you please confirm that using "--no-strip" in genkernel's cmdline will fix the problem? If not, it is not cause by https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=c2525c65b9f3d5849963bab6beb40817d7720218
Comment 8 Anna Tikhomirova 2017-06-28 13:52:45 UTC
(In reply to Thomas Deutschmann from comment #7)
> Can you please confirm that using "--no-strip" in genkernel's cmdline will
> fix the problem? If not, it is not cause by
> https://gitweb.gentoo.org/proj/genkernel.git/commit/
> ?id=c2525c65b9f3d5849963bab6beb40817d7720218

Yes, adding --no-strip fixes the "invalid magic number" problem.

It does not fix the missing kernel drivers though, but that's the subject for another bug report.
Comment 9 Thomas Deutschmann (RETIRED) gentoo-dev 2017-06-28 14:06:45 UTC
PMASKED for the moment, https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2db5f9926ec5fe7235e60a10cc98d83756f77d40


Could anyone experiencing the the strip problem please attach his/her kernel config and tell us if he/she is using a bootloader or plain EFI?
Comment 10 Joonas Niilola gentoo-dev 2017-06-28 14:21:36 UTC
Created attachment 478278 [details]
kernel-config-x86_64-4.11.0-pf6

(In reply to Thomas Deutschmann from comment #9)
> PMASKED for the moment,
> https://gitweb.gentoo.org/repo/gentoo.git/commit/
> ?id=2db5f9926ec5fe7235e60a10cc98d83756f77d40
> 
> 
> Could anyone experiencing the the strip problem please attach his/her kernel
> config and tell us if he/she is using a bootloader or plain EFI?

Hey, 

I ran into this problem. Just using genkernel made an unbootable image with "invalid magic number" error message. After adding --no-strip parameter, it loaded the image, but failed to boot because it couldnt find partitions (same error as mentioned in this bug earlier). Downgrading genkernel to 3.5.0.8 fixed everything and made a kernel upgrade bootable. I can attach my kernel config, but Im not sure if Im using a bootloader or EFI. Im quite sure though that Im using a bootloader.
Comment 11 Anna Tikhomirova 2017-06-28 14:29:25 UTC
Created attachment 478282 [details]
kernel-config-x86_64-4.11.7-gentoo

I'm using Legacy (BIOS) boot + bootloader (Grub2).
Comment 12 Anna Tikhomirova 2017-06-28 14:58:02 UTC
I've looked at the strip feature patch. It seems that the patch is completely wrong, at least in the kernel stripping part. It tries to strip bzImage, which is the compressed kernel image + decompressor. The result is just the broken bzImage header.
If you want to strip a kernel, you should strip an uncompressed image (and somehow  make bzImage from it).
Comment 13 Anna Tikhomirova 2017-06-28 15:35:12 UTC
(In reply to Joonas Niilola from comment #10)
> After adding --no-strip parameter, it
> loaded the image, but failed to boot because it couldnt find partitions
> (same error as mentioned in this bug earlier).

I've opened bug #622930 for initramfs issue.
Comment 14 Gabriel D'Ambrosio 2017-06-28 16:49:54 UTC
Created attachment 478302 [details]
kernel-config-x86_64-4.11.7-gentoo

Using: LUKS, LVM and UEFI.
Comment 15 Wes 2017-06-30 01:52:32 UTC
(In reply to Andrey Tikhomirov from comment #5)
> It does not load scsi drivers,
> resulting in "Could not find the root block device".
> 
> I think someone should open a separate bug report for this.

You are right, thanks for filing the separate bug report
Comment 16 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2017-07-14 18:50:08 UTC
[master fa341eb] Fix unbootable kernels due to overzealous strip.
 4 files changed, 5 insertions(+), 11 deletions(-)
Comment 17 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2017-07-14 19:59:40 UTC
Released in 3.5.1.1, please test
Comment 18 Gabriel D'Ambrosio 2017-07-15 04:34:04 UTC
(In reply to Robin Johnson from comment #17)
> Released in 3.5.1.1, please test

3.5.1.1 Works without problem. Thanks!