Bug#646284: dropping applets-fallback breaks initramfs images

2011-10-22 Thread Stefan Lippers-Hollmann
Package: busybox
Version: 1:1.19.2-1
Severity: grave
Justification: Breaks system booting using initramfs-tools in non-trivial ways.
Tags: patch
X-Debbugs-CC: Debian kernel team debian-ker...@lists.debian.org

Hi

Initramfs images generated by initramfs-tools 0.99 after busybox got 
upgraded to 1:1.19.2-1 fail to boot with the following error messages:

Loading, please wait...
/init: line 11: mount: not found
/init: line 12: mount: not found
/init: line 25: mount: not found
W: devtmpfs not available, falling back to tmpfs for /devtmpfs
/init: line 25: mount: not found
/init: line 27: mount: not found
/init: line 28: mount: not found
cat: can't open '/proc/cmdline': No such file or directory
cat: can't open '/proc/cmdline': No such file or directory
/scripts/init-top/udev: line 14: can't create /sys/kernel/uevent_helper: 
nonexistent directory
Begin: Loading essential drivers ... done
Begin: Running /scripts/init-premount ... done
Begin: Mounting root file system .. Begin: Running /scripts/local-top .. [
0.742185] device-mapper: uevent: version 1.0.3
[0.746854] device-mapper: ioctl 4.21.0-ioctl (2011-07-06) initialised: 
dm-de...@redhat.com
done.
Begin: Running /scripts/local-premount ... [ 0.765009] Btrfs loaded
done.
/init: line 5: mount: not found
Begin: Running /scripts/local-bottom ... done
done.
Begin: Running /scripts/init-bottom ... done
/init: line 239: mv: not found
/init: line 239: umount: not found
/init: line 242: mount: not found
/init: line 243: mount: not found
Target filesystem doesn't have requested /sbin/init.
/init: line 291: chvt: not found
No init found. Try passing init= bootarg.


BusyBox v1.19.2 (Debian 1:1.19.2-1) built-in shell (ash)
Enter 'help' for a list of built-in commands.

/bin/sh: can't access tty; job control turned off
(initramfs)


needed initramfs-tools hooks on this system:

$ dpkg -S /usr/share/initramfs-tools/hooks/*
initramfs-tools: /usr/share/initramfs-tools/hooks/busybox
dmsetup: /usr/share/initramfs-tools/hooks/dmsetup
initramfs-tools: /usr/share/initramfs-tools/hooks/keymap
initramfs-tools: /usr/share/initramfs-tools/hooks/klibc
lvm2: /usr/share/initramfs-tools/hooks/lvm2
initramfs-tools: /usr/share/initramfs-tools/hooks/thermal
udev: /usr/share/initramfs-tools/hooks/udev

Re-instating applets-fallback.patch in busybox 1:1.19.2-1 however fixes
this reproducable boot failure, quick'n'dirty rediff (tested on 
amd64  i386, using systems with mdadm, lvm2 or nothing special at 
all) attached.

Regards
Stefan Lippers-Hollmann

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.1-rc10-aptosid-amd64 (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages busybox depends on:
ii  libc6  2.13-21

busybox recommends no packages.

busybox suggests no packages.

-- no debconf information
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7394,23 +7394,8 @@ static int builtinloc = -1; /* index
 
 
 static void
-tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char **envp)
+tryexec(char *cmd, char **argv, char **envp)
 {
-#if ENABLE_FEATURE_SH_STANDALONE
-	if (applet_no = 0) {
-		if (APPLET_IS_NOEXEC(applet_no)) {
-			clearenv();
-			while (*envp)
-putenv(*envp++);
-			run_applet_no_and_exit(applet_no, argv);
-		}
-		/* re-exec ourselves with the new arguments */
-		execve(bb_busybox_exec_path, argv, envp);
-		/* If they called chroot or otherwise made the binary no longer
-		 * executable, fall through */
-	}
-#endif
-
  repeat:
 #ifdef SYSV
 	do {
@@ -7465,24 +7450,21 @@ shellexec(char **argv, const char *path,
 	int e;
 	char **envp;
 	int exerrno;
-#if ENABLE_FEATURE_SH_STANDALONE
-	int applet_no = -1;
-#endif
 
 	clearredir(/*drop:*/ 1);
 	envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL);
-	if (strchr(argv[0], '/') != NULL
-#if ENABLE_FEATURE_SH_STANDALONE
-	 || (applet_no = find_applet_by_name(argv[0])) = 0
-#endif
-	) {
-		tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) argv[0], argv, envp);
+	if (strchr(argv[0], '/') != NULL) {
+		tryexec(argv[0], argv, envp);
 		e = errno;
 	} else {
+#if ENABLE_FEATURE_SH_STANDALONE
+		bb_execv_applet(argv[0], argv, envp);
+#endif
+
 		e = ENOENT;
 		while ((cmdname = path_advance(path, argv[0])) != NULL) {
 			if (--idx  0  pathopt == NULL) {
-tryexec(IF_FEATURE_SH_STANDALONE(-1,) cmdname, argv, envp);
+tryexec(cmdname, argv, envp);
 if (errno != ENOENT  errno != ENOTDIR)
 	e = errno;
 			}
--- a/libbb/execable.c
+++ b/libbb/execable.c
@@ -9,6 +9,9 @@
 
 #include libbb.h
 
+#include alloca.h
+#include stdarg.h
+
 /* check if path points to an executable file;
  * return 1 if found;
  * return 0 otherwise;
@@ -68,13 +71,60 @@ int FAST_FUNC exists_execable(const char
 }
 
 #if ENABLE_FEATURE_PREFER_APPLETS
+int FAST_FUNC bb_execv_applet(const char *name, char *const argv[], char *const 

Bug#646284: dropping applets-fallback breaks initramfs images

2011-10-22 Thread Michael Tokarev
On 23.10.2011 01:49, Stefan Lippers-Hollmann wrote:
 Package: busybox
 Version: 1:1.19.2-1
 Severity: grave
 Justification: Breaks system booting using initramfs-tools in non-trivial 
 ways.
 Tags: patch
 X-Debbugs-CC: Debian kernel team debian-ker...@lists.debian.org
 
 Hi
 
 Initramfs images generated by initramfs-tools 0.99 after busybox got 
 upgraded to 1:1.19.2-1 fail to boot with the following error messages:
 
 Loading, please wait...
 /init: line 11: mount: not found
...

Yes, applets-fallback was a dirty hack, and I tried to get rid of it,
and I asked kernel team several times about using regular ways to invoke
busybox commands in initramfs, but only got Later so far.  I tempted
to reassign this bug to initramfs-tools, but wont do that yet.

And no, it wasn't really expected - I hoped that CONFIG_FEATURE_PREFER_APPLETS
will take care of this.  Apparently not, and I wonder why it is so.

.. ah, I see now: it is because initramfs does not put busybox as /bin/busybox
as it expects to be found, but copies it to /bin/sh.  So, with previously
applied applets-fallback, it tried to execute /proc/self/exe AND /bin/busybox,
and without that patch, it tries just /bin/busybox.  Sigh.

[]
 Re-instating applets-fallback.patch in busybox 1:1.19.2-1 however fixes
 this reproducable boot failure, quick'n'dirty rediff (tested on 
 amd64  i386, using systems with mdadm, lvm2 or nothing special at 
 all) attached.

Thank you for the quick fix - something I tried to do yesterday but failed.

It is my intention to get rid of this ugly hack before wheezy, but unfortunately
kernel team does not want to cooperate.  So for now, I'll include this hack
again, and file a bug against initramfs-tools properly.

/mjt



-- 
To UNSUBSCRIBE, email to debian-boot-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/4ea34564.9070...@msgid.tls.msk.ru