Bug 115556 - /init crashes in initramfs
Summary: /init crashes in initramfs
Status: RESOLVED FIXED
Alias: None
Product: SUSE LINUX 10.0
Classification: openSUSE
Component: Kernel (show other bugs)
Version: Beta 4
Hardware: x86-64 All
: P5 - None : Critical
Target Milestone: ---
Assignee: Hannes Reinecke
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-07 06:54 UTC by Hannes Reinecke
Modified: 2005-12-18 18:54 UTC (History)
1 user (show)

See Also:
Found By: Development
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
screenlog.1 (74.72 KB, text/plain)
2005-09-07 06:55 UTC, Hannes Reinecke
Details
init (12.40 KB, text/plain)
2005-09-07 06:56 UTC, Hannes Reinecke
Details
screenlog.2 (8.71 KB, text/plain)
2005-09-07 07:26 UTC, Hannes Reinecke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hannes Reinecke 2005-09-07 06:54:24 UTC
Whilst trying to get NFS root to work my machine always crashes in /init with
mysterious error codes; mostly parsing errors from sh.

When running under strace (in the same environment) the machine stopped with:

...
write(2, ": proc udev_", 12: proc udev_)        = 12
read(10, 0x528680, 4088)                      = -1 EBADF (Bad file descriptor)
write(2, "+ ", 2+ )                               = 2
write(2, ":", 1:)                                = 1
write(2, " proc", 5 proc)                           = 5
write(2, " udev_", 6 udev_)                          = 6
write(2, "\n", 1
)                       = 1
_exit(0)
Kernel panic - not syncing: Attempted to kill init

Uh-oh ...
Comment 1 Hannes Reinecke 2005-09-07 06:55:58 UTC
Created attachment 49014 [details]
screenlog.1

Logfile captured from serial console. Doesn't show everything, I'm afraid, as
the kernel panic occured before everything was flushed.
Comment 2 Hannes Reinecke 2005-09-07 06:56:59 UTC
Created attachment 49015 [details]
init

/init script used within the initramfs
Comment 3 Hannes Reinecke 2005-09-07 07:26:08 UTC
Created attachment 49016 [details]
screenlog.2

Full screenlog; most clutter removed.
Comment 4 Andreas Gruenbacher 2005-09-07 07:45:36 UTC
This seems to be the relevant part: this shell closes its sourcefile when it 
sources dhcpcd-eth0.info. 
 
open("/init.real", O_RDONLY)            = 3 
dup2(3, 10)                             = 10 
read(10, "#! /bin/sh\n\nexport PATH=/sbin:/u"..., 4088) = 4088 
 
open("/var/lib/dhcpcd/dhcpcd-eth0.info", O_RDONLY) = 3 
dup2(3, 10)                             = 10 
[...original fd 10 now and not saved anywhere...] 
close(3)                                = 0 
read(10, "IPADDR=10.10.101.227\nNETMASK=255"..., 4088) = 657 
read(10, "", 4088)                      = 0 
close(10)                               = 0 
 
[...some more temporary use of fd 10, eventually closing it again...] 
read(10, 0x528680, 4088)                = -1 EBADF (Bad file descriptor) 
Comment 5 Hannes Reinecke 2005-09-07 08:11:30 UTC
Yep. there is a bug in /lib/klibc/bin/sh; dup2() will close the destination fd
if already open. One should use fcntl() to always get a new free fd.
Comment 6 Hannes Reinecke 2005-09-07 08:14:50 UTC
Raising priority as this potentially affects all installations.
Comment 7 Hannes Reinecke 2005-09-07 10:52:42 UTC
Fixed klibc submitted to stable.
Comment 8 Ihno Krumreich 2005-09-07 14:43:25 UTC
Just use dup() instead of dup2()  
Comment 9 Ihno Krumreich 2005-12-18 18:54:53 UTC
closed.