FS#23467 - [mkinitcpio] 0.6.9-1: /init crashes when parsing command line parameters

Attached to Project: Arch Linux
Opened by Karl Kochs (K4ph) - Sunday, 27 March 2011, 17:14 GMT
Last edited by Andrea Scarpino (BaSh) - Monday, 25 April 2011, 21:45 GMT
Task Type Bug Report
Category Packages: Testing
Status Closed
Assigned To Thomas Bächler (brain0)
Architecture All
Severity Critical
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description: mkinitcpio 0.6.9-1 creates a kernel-panic after reboot

Additional info:
* package version mkinitcpio 0.6.9-1 and kernel 2.6.38.1-1
* config and/or log files etc.


Steps to reproduce:
installing mkinitcpio 0.6.9-1 and running mkinitcpio -p kernel26 ended in a kernal panic after reboot. Downgrading to mkinitcpio 0.6.8-2 and another mkinitcpio -p kernel26 fixed the issue.
This task depends upon

Closed by  Andrea Scarpino (BaSh)
Monday, 25 April 2011, 21:45 GMT
Reason for closing:  Fixed
Additional comments about closing:  mkinitcpio 0.6.11-1
Comment by Thomas Bächler (brain0) - Sunday, 27 March 2011, 18:13 GMT
Can you please provide ANY information? I don't even know where to start asking, as your report essentially contains nothing.

Maybe we can start with the symptoms: I need the full contents of the screen when the panic occurs.
Comment by Rémy Oudompheng (remyoudompheng) - Sunday, 27 March 2011, 18:15 GMT
Hello, please detail the contents of your mkinitcpio.conf and of course, the kernel panic message details, otherwise nobody can work on that issue.
Comment by smartcat99s (smartcat99s) - Tuesday, 29 March 2011, 06:01 GMT
I see this on a system that is EFI booted from Grub 2 (bzr build) to kernel26-2.6.38.1

:: Loading Initramfs
:: Starting udevd...
done.udev[45]: starting version 166

/init: eval: line 1: syntax error: unexpected "("
Kernel panic - not syncing: Attempted to kill init!
Pid:1, comm init Not tainted 2.6.38-ARCH #1


I downgraded to core/mkinitcpio-0.6.8-2 and it worked. mkinitcpio.conf is below (comments removed)

MODULES="ahci libahci ehci-hcd ext2 btrfs vfat crc32c"
BINARIES=""
FILES=""
HOOKS="base udev autodetect scsi sata btrfs filesystems"
Comment by Thomas Bächler (brain0) - Tuesday, 29 March 2011, 08:57 GMT
Thanks, this is very useful. I also need the contents of /proc/cmdline to debug this.

EDIT: Hm, you are not the original reporter. I feel confident that he experiences the same problem though.
Comment by Thomas Bächler (brain0) - Tuesday, 29 March 2011, 08:59 GMT
Btw, this is most likely the offending commit that introduced the 'eval' statements: https://projects.archlinux.org/mkinitcpio.git/commit/?id=42e8dba5dce4879e4a372c5c2fb5446b4e8bb16c
Comment by smartcat99s (smartcat99s) - Tuesday, 29 March 2011, 15:36 GMT
From a working boot with 0.6.8-2:
BOOT_IMAGE=(hd0,gpt4)/vmlinuz26 root=/dev/sda6 rootfstype=btrfs ro
Comment by Thomas Bächler (brain0) - Tuesday, 29 March 2011, 16:59 GMT
Thanks. Let me see what I can come up with. Parsing this BOOT_IMAGE part is redundant anyway.
Comment by Karl Kochs (K4ph) - Wednesday, 30 March 2011, 10:28 GMT
Well, trying to update to 2.6.38.2 with another try of mkinitcpio 0.6.9 this time SHOWED me a kernel panic (before I had blank screen):

input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input0
/init: eval: line 1: syntax error: unexpected "("
Kernel panic - not syncing: Attempted to kill init!
Pid: 1, comm: init Not tainted 2.6.38-ARCH #1
Call Trace:
[<ffffffff813a90d0>] ? panic+0x9b/0x1a8
[<ffffffff8105cc04>] ? do_exit+0x8a4/0x8b0
[<ffffffff8105cf4f>] ? do_group_exit+0x3f/0xa0
[<ffffffff8105cfc2>] ? sys_exit_group+0x12/0x20
[<ffffffff8100ae12>] ? system_call_fastpath+0x16/0x1b

Again, rescuebooting LTS and downgrading mkinitcpio to 0.6.8-2 and another mkinitcpio -p kernel26 fixed this for me.
Comment by Thomas Bächler (brain0) - Wednesday, 30 March 2011, 10:59 GMT
Thanks. This is indeed the same problem as described by smartcat99s. I'll have it fixed in the next few days, please stay with mkinitcpio 0.6.8 until then.
Comment by Anonymous Submitter - Thursday, 31 March 2011, 14:38 GMT
I had the same problem with grub2-efi-x86_64. The grub2 devs at #grub in freenode pointed out the problem in /init in the initramfs. The problem is the linux command line uses

linux (hd0,gpt4)/vmlinuz26 root=/dev/sda3 rootfstype=ext4 ro nomodeset
initrd (hd0,gpt4)/kernel26.img

Using

set root=(hd0,gpt4)
linux /vmlinuz26 root=/dev/sda3 rootfstype=ext4 ro nomodeset
initrd /kernel26.img

corrected the problem (ie. no brackets in the kernel commandline, otherwise /init in the initramfs fails). Dave (falconindy) pointed out http://projects.archlinux.org/mkinitcpio.git/commit/?id=42e8dba5dce4879e4a372c5c2fb5446b4e8bb16c commit to be the exact cause of the problem.


Comment by Thomas Bächler (brain0) - Thursday, 31 March 2011, 15:06 GMT
I already know where the problem is and I pointed out that commit in an earlier comment. I also have a solution in mind (which also might solve some other bugs). I just need to implement it, which probably won't happen before Monday.
Comment by Thomas Bächler (brain0) - Tuesday, 05 April 2011, 16:21 GMT Comment by smartcat99s (smartcat99s) - Tuesday, 05 April 2011, 17:39 GMT
Yes, I no longer crash with that commit applied.
Comment by Evan (Evanlec) - Thursday, 07 April 2011, 03:28 GMT
I can confirm this as well. Using grub2-bios
Installed from Archboot CD, but I suspect this may be true for grub2-bios in general...
It automatically setup my /boot/grub/grub.cfg as so (this is only from memory so maybe not completely right):

# (0) Arch Linux
menuentry "Arch Linux" {
search --label --no-floppy --set=root boot
linux $(boot)/vmlinuz26 root=/dev/sda3 rootflags=,subvol=master,compress=lzo rootfstype=btrfs ro radeon.modeset=1 quiet init=/bin/systemd
initrd /kernel26.img

The auto-search thing worked before one of the latest upgrades...then I got the same error as above. the '(' caused kernel panic. Fixed by simply removing the search line and the $(boot)
Comment by Thomas Bächler (brain0) - Sunday, 10 April 2011, 20:32 GMT
Please confirm that mkinitcpio 0.6.10 fixes the problem.
Comment by Karl Kochs (K4ph) - Sunday, 10 April 2011, 21:43 GMT
Sorry, to say so, but I can't confirm it.
After installing 0.6.10-1, doing a mkinitcpio -p kernel26 (I use x86_64), I got again after a reboot the kernel panic ...
panic
do_exit
do_group_exit
sys_exit_group
system_call_fastpath
Comment by Thomas Bächler (brain0) - Sunday, 10 April 2011, 22:20 GMT
Okay, I reintroduced the bug while fixing another one (should have done more testing here), this commit is the bad guy: https://projects.archlinux.org/mkinitcpio.git/commit/?id=d1264eb145c0aa0adc219dfb71fa5d7acc4e26ff

The eval is again the problem, I'll need to do more to fix this entirely.
Comment by Dave Reisner (falconindy) - Monday, 11 April 2011, 10:24 GMT
@thomas: Your original work with export was "correct". I didn't understand why you switched to eval. eval is evil and will strip quotes, mangle data, and kick your cat.

So, I think that we need to enforce usage of octal escapes for spaces (similar to fstab), otherwise there's no sane way of parsing strings. /usr/bin/printf as well as busybox's printf both support the %b formatter mentioned below in the SO link.

http://stackoverflow.com/questions/993452/splitting-proc-cmdline-arguments-with-spaces
Comment by Thomas Bächler (brain0) - Monday, 11 April 2011, 10:33 GMT
The 'export' is not correct, we don't want to fill the environment with useless variables.
Comment by Dave Reisner (falconindy) - Monday, 11 April 2011, 11:37 GMT
I'm trying to pin down where the environment is cleared between initcpio and agetty, but I'm not having much luck (though I suspect its in init). The bottom line is that my current initcpio still uses export and _none_ of the variables exported during the initcpio's pid 1 make it down to my environment on the cmdline. Where are you seeing this pollution?
Comment by Thomas Bächler (brain0) - Thursday, 14 April 2011, 20:45 GMT
Karl, sorry for the delay. Can you apply the attached patch on top of mkinitcpio 0.6.10 and try? This should really fix it for good.
Comment by Thomas Bächler (brain0) - Thursday, 14 April 2011, 21:45 GMT
The first one had a small mistake, use this one instead.
Comment by Karl Kochs (K4ph) - Thursday, 14 April 2011, 22:02 GMT
patch /sbin/mkinitcpio < fix-parse-cmdline.patch
patching file /sbin/mkinitcpio
Hunk #1 FAILED at 31.
1 out of 1 hunk FAILED -- saving rejects to file /sbin/mkinitcpio.rej

That's what I got, trying to patch it with the 3.2 KiB patch. Am I patching it the wrong way?
Comment by Thomas Bächler (brain0) - Thursday, 14 April 2011, 22:15 GMT
This patch applies to /lib/initcpio/init_functions, not /sbin/mkinitcpio.
Comment by Karl Kochs (K4ph) - Thursday, 14 April 2011, 22:16 GMT
Done. Okay, I'm using mkinitcpio - in around 10 mins, you should get my answer, if it works. -.^
Comment by Karl Kochs (K4ph) - Thursday, 14 April 2011, 22:55 GMT
Thank you very much, Thomas. It's four times a go.
Tested it first successfully with kernel26 x86_64.
After that I tested also:
kernel26-lts x86_64
kernel26-mainline x86_64
kernel26-lqx x86_64
and last but not least ...
kernel26 i686 (on my wifes netbook).
It's a solution - and it works!
Comment by Thomas Bächler (brain0) - Friday, 15 April 2011, 09:09 GMT
Great. I should be able to push 0.6.11 pretty soon then (which can finally move to core).

Loading...