Bug#679377: Segmentation fault when initramfs is booting

2012-07-08 Thread Stefan Lippers-Hollmann
Hi

On Saturday 07 July 2012, Michael Tokarev wrote:
[…]
 On 05.07.2012 15:12, Jordi Pujol wrote:
 []
  the patch shell-ash-export-HOME.patch causes a segmentation fault when
  initramfs boots,
  I believe that this fault occurs the first time that initramfs looks for
  some executable in the initramfs filesystem,
 
 Big thanks to Denys Vlasenko, the issue has been identified.
[…]
 I added a temporary workaround to this patch - making
 the default PATH variable to be non-const, ie, writable,
 this way awk will be able to write to it.  No other parts
 of the code tries to write to it, so it is a safe change.
[…]

Thanks a lot for your and Denys Vlasenko's efforts, this workaround in 
busybox 1:1.20.0-5 works fine for my use case :)

Regards
Stefan Lippers-Hollmann



--
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/201207090235.10692.s@gmx.de



Bug#679377: Segmentation fault when initramfs is booting

2012-07-07 Thread Michael Tokarev
retitle 679377 busybox awk segfaults when called from ash and no PATH set (eg 
initramfs /init)
tags 679377 + pending
thanks

On 05.07.2012 15:12, Jordi Pujol wrote:
[]
 the patch shell-ash-export-HOME.patch causes a segmentation fault when
 initramfs boots,
 I believe that this fault occurs the first time that initramfs looks for
 some executable in the initramfs filesystem,

Big thanks to Denys Vlasenko, the issue has been identified.

awk applet, when initializes, converts environment variables
into awk internal variables, and while doing this, it temporary
replaces the equal sign (=) in ther with a null byte (\0).

awk applet is marked as NOEXEC, ie, it is okay to run it directly
from shell just by calling appropriate awk_main() routine, without
executing any external program.

When ash tries to run such applet, it initializes environment
variables first, and calls the applet's main() function.

The patch in question exports PATH variable with its default
value.  But this value is stored in a global CONSTANT variable
(marked as const).  All other exported variables are
in malloc'ed memory.

Also, when awk is run as a separate command, the kernel sets
environment variables to be completely writable.

So this very case - calling awk applet from ash when no
PATH variable has been set - is the only case when ONE
environment variable - PATH - is not writable.  And when
awk applet initializes and tries to replace = with \0,
it segfaults.

I added a temporary workaround to this patch - making
the default PATH variable to be non-const, ie, writable,
this way awk will be able to write to it.  No other parts
of the code tries to write to it, so it is a safe change.

I can't drop this patch now, since it is too risky change
at this stage in wheezy release.  This rather obscure
case were difficult enough to debug, and I don't want
to introduce another obscure issue in some other component
while wheezy is frozen.

By the way, the same issue can be reproduced much, much
more easily:

 $ env -i /bin/busybox ash -c awk
 Segmentation fault

That was the missing part: no environment variables are
set, including $PATH.

Thanks,

/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/4ff8b03e.9030...@msgid.tls.msk.ru



Processed: Re: Bug#679377: Segmentation fault when initramfs is booting

2012-07-07 Thread Debian Bug Tracking System
Processing commands for cont...@bugs.debian.org:

 retitle 679377 busybox awk segfaults when called from ash and no PATH set (eg 
 initramfs /init)
Bug #679377 [busybox] Segmentation fault when initramfs is booting
Changed Bug title to 'busybox awk segfaults when called from ash and no PATH 
set (eg initramfs /init)' from 'Segmentation fault when initramfs is booting'
 tags 679377 + pending
Bug #679377 [busybox] busybox awk segfaults when called from ash and no PATH 
set (eg initramfs /init)
Added tag(s) pending.
 thanks
Stopping processing here.

Please contact me if you need assistance.
-- 
679377: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=679377
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems


--
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/handler.s.c.134169811615309.transcr...@bugs.debian.org



Bug#679377: Segmentation fault when initramfs is booting

2012-07-05 Thread Jordi Pujol
A Dimecres, 4 de juliol de 2012 18:08:30, Michael Tokarev va escriure:
 tags 679377 + moreinfo
 thanks
 
 On 28.06.2012 13:14, Jordi Pujol wrote:
  Package: busybox
  Version: 1:1.20.0-4
  Severity: important
  
  the patch shell-ash-export-HOME.patch causes a segmentation fault when
  initramfs boots,
  I believe that this fault occurs the first time that initramfs looks for
  some executable in the initramfs filesystem,
 
 Does whole thing actually work?  Why do you think it is this patch
 which causes the SIGSEGV?  The change in this patch is quite, well,
 innocent, it does not look like it can be a cause for any such issues.
 
This works now, using the modified version,
There are a few weeks, after the upgrade 
of Busybox, the system not booted; 
automatically it entered in the Busybox shell, and we see Segmentation 
fault... in the file /run/initramfs/initramfs.debug
Trying the new version 1.20.1 from upstream, with their stable patches, 
allways boots.
Adding the old patches to that, this little patch makes the boot fail,

I believe that some built-in Busybox commands access to internal memory tables 
that are not initialized yet,
These tables may be initialized with some commands that manage paths or 
directories. (It's supposed, from experiences).

 Can you describe your initramfs/environment a bit?  Maybe give me
 access to your initramfs for testing?
my initramfs is based in Debian Live initramfs, in their mailing-list they 
have been talking about that and it's solved with a workaround. This 
workaround re-creates a directory (mkdir -p) that already exists.

http://lists.debian.org/CAFp4thR1VTaWJxjO1G0A--
N3ww8Mnrf3E=pe0wtye_ztexc...@mail.gmail.com

 
  Also, the latest release of busybox, 1.20.1 is a bit different of that,
  and
 
 Different of what, exactly?  The version of busybox you're
 filing bugreport against is actually 1.20.1, so there are
 two questions actually: what is different, and different
 between what and what? -- since you're comparing the same
 thing with itself.
Sorry, a detailed look shows that I was magnifying the things, there is only 
one diff,

diff -Naurp ../busybox-1.20.0/shell/ash.c ../busybox-1.20.1-lnet1/shell/ash.c
--- ../busybox-1.20.0/shell/ash.c   2012-07-05 12:11:06.0 +0200
+++ ../busybox-1.20.1-lnet1/shell/ash.c 2012-04-22 03:45:24.0 +0200
@@ -6846,7 +6846,8 @@ evalvar(char *p, int flags, struct strli
patloc = expdest - (char *)stackblock();
if (NULL == subevalvar(p, /* varname: */ NULL, patloc, subtype,
startloc, varflags,
-   /* quotes: */ flags  (EXP_FULL | EXP_CASE | 
EXP_REDIR),
+//TODO: | EXP_REDIR too? All other such places do it too
+   /* quotes: */ flags  (EXP_FULL | EXP_CASE),
var_str_list)
) {
int amount = expdest - (

 So, I really want to know more about your environment and
 the segfault.  I don't see any segfaults here.
This Segmentation fault is really difficult to debug, it's supposed that occurs 
depending on the instruccions contained in every script,

Here is a saved log of an execution, using a modified Debian Live initramfs 
that traps all errors,

...
+ maybe_break mount
+ [  = mount ]
+ log_begin_msg Mounting root file system
+ _log_msg Begin: Mounting root file system ... 
+ [ n = y ]
+ printf Begin: Mounting root file system ... 
Begin: Mounting root file system ... + . /scripts/lnet
+ export LANG=C
+ LNET_LIVEPOINT=/lnet
+ mountpoint=/lnet/image
+ LNET_MEDIA_PATH=LneT
+ LNET_LIVEVARS=/etc/lnet.vars
+ LNET_USERNAME=livenet
+ LNET_USERFULLNAME=Live never ending Tale user
+ LNET_HOSTNAME=Live-neT
+ [ -z -qb ]
+ LNET_MODPROBE_OPTIONS=-qb
+ . /scripts/functions
+ set -e
+ trap set +e ; trap - 0 ; panic Error in ${0} 0
+ touch /etc/mtab
+ mkdir -p /lnet
+ awk /MemTotal:/{print $2} /proc/meminfo
Segmentation fault...
(next the panic routine is executed...)

All the commands are built-in Busybox commands,

It has been not possible to save a log in Debian Live; in this environment 
after the error the shell was locked or unresponsible,

it seems that everyone has solved this, in a form or other, change the 
severity to normal, if you want.

Thanks,

Jordi Pujol

Live never ending Tale
GNU/Linux Live forever!
http://livenet.selfip.com



-- 
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/201207051312.42206.jordipuj...@gmail.com



Bug#679377: Segmentation fault when initramfs is booting

2012-07-05 Thread Michael Tokarev
On 05.07.2012 04:32, Stefan Lippers-Hollmann wrote:
[]
 I'm having trouble with the same problem in a custom (not Debian live)
 live boot environment, where busybox awk segfaults with 
 shell-ash-export-HOME.patch applied. The code in question is[1]:
 
 FINGERED=$(awk -F: '
[]
 Executing the very same awk command from the initramfs shell (busybox 
 ash) afterwards succeeds however:

It looks like the problem only happens with awk and only
when it is called as awk (not busybox awk and not /bin/awk
after adding a symlink with this name pointing to busybox)
and only when it is called from pid=1.

For example, I did some experiments, and put a simple
awk call in a separate file /at.  Executing it from
/init does not produce segfault, but sourcing it does
(so it only happens with pid==1).

I can only guess it is due to awk being NOEXEC applet.

This is a problem very difficult to debug.  I'll try
to get something out of this all.

Thank you!

/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/4ff5880a@msgid.tls.msk.ru



Bug#679377: Segmentation fault when initramfs is booting

2012-07-04 Thread Michael Tokarev
tags 679377 + moreinfo
thanks

On 28.06.2012 13:14, Jordi Pujol wrote:
 Package: busybox
 Version: 1:1.20.0-4
 Severity: important
 
 the patch shell-ash-export-HOME.patch causes a segmentation fault when 
 initramfs boots,
 I believe that this fault occurs the first time that initramfs looks for some 
 executable in the initramfs filesystem,

Does whole thing actually work?  Why do you think it is this patch
which causes the SIGSEGV?  The change in this patch is quite, well,
innocent, it does not look like it can be a cause for any such issues.

Can you describe your initramfs/environment a bit?  Maybe give me
access to your initramfs for testing?

 Also, the latest release of busybox, 1.20.1 is a bit different of that, and 

Different of what, exactly?  The version of busybox you're
filing bugreport against is actually 1.20.1, so there are
two questions actually: what is different, and different
between what and what? -- since you're comparing the same
thing with itself.

 more upstream stable patches have been added. A new release can be packaged 
 containing this changes,

The only upstream change not included in debian package is
busybox-1.20.1-mke2fs.patch, which is only relevant for
busybox-static since other variants don't enable mkfs.

 Modifying this, busybox works fine,
 
 http://livenet.selfip.com/ftp/debian/package-
 modifications/busybox_1.20.1-1.lnet1.debian.tar.gz

Now that's fantastic.  Let's see.

diff -u -p -r debian/patches/series lnet/patches/series
--- 1.20.0-4/patches/series 2012-06-12 22:04:46.0 +0400
+++ lnet1/patches/series2012-06-22 19:15:34.0 +0400
@@ -1,6 +1,4 @@
-1.20.1.patch
-
-shell-ash-export-HOME.patch
+#shell-ash-export-HOME.patch
 # we need to get rid of this one:
 #applets-fallback.patch
 version.patch
@@ -11,10 +9,12 @@ u-mount-FreeBSD-support.patch
 swaponoff-FreeBSD-support.patch

 # FTBFS on non-linux
-ps-get-uptime.patch
+#ps-get-uptime.patch

 # upstream stable patches
 busybox-1.20.1-ash.patch
 busybox-1.20.1-ifupdown.patch
 busybox-1.20.1-man.patch
+busybox-1.20.1-mke2fs.patch
+busybox-1.20.1-ps.patch
 busybox-1.20.1-tar.patch

So you reverted all fixes which went into 1.20.1 bugfix
release, you reverted my ps-get-uptime.patch but added
busybox-1.20.1-ps.patch (it has exactly the same content),
added busybox-1.20.1-mke2fs.patch (which is not relevant
for the issue in question), and reverted shell-ash-export-HOME.patch
which looks completely innocent here, without trying to
understand what it does and WHY it is here.

Wherer's the improvement?  This is definitely NOT a way
to do things.

So, I really want to know more about your environment and
the segfault.  I don't see any segfaults here.

Thanks,

/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/4ff46a7e.4040...@msgid.tls.msk.ru



Processed: Re: Bug#679377: Segmentation fault when initramfs is booting

2012-07-04 Thread Debian Bug Tracking System
Processing commands for cont...@bugs.debian.org:

 tags 679377 + moreinfo
Bug #679377 [busybox] Segmentation fault when initramfs is booting
Added tag(s) moreinfo.
 thanks
Stopping processing here.

Please contact me if you need assistance.
-- 
679377: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=679377
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems


--
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/handler.s.c.134141811716457.transcr...@bugs.debian.org



Bug#679377: Segmentation fault when initramfs is booting

2012-07-04 Thread Stefan Lippers-Hollmann
Hi

On Wednesday 04 July 2012, Michael Tokarev wrote:
[…]
 On 28.06.2012 13:14, Jordi Pujol wrote:
[…] 
  the patch shell-ash-export-HOME.patch causes a segmentation fault when 
  initramfs boots,
  I believe that this fault occurs the first time that initramfs looks for 
  some 
  executable in the initramfs filesystem,
 
 Does whole thing actually work?  Why do you think it is this patch
 which causes the SIGSEGV?  The change in this patch is quite, well,
 innocent, it does not look like it can be a cause for any such issues.

I'm having trouble with the same problem in a custom (not Debian live)
live boot environment, where busybox awk segfaults with 
shell-ash-export-HOME.patch applied. The code in question is[1]:

FINGERED=$(awk -F: '
$1 == drive name  NF  1 {
split($2, node,  )
for (n in node) {
if (!system(test -b /dev/ node[n]))
cdrom[i++] = /dev/ node[n]
}
}
END {
for (c in cdrom)
print cdrom[c]
}
' /proc/sys/dev/cdrom/info)

Leading to:

Loading, please wait...
modprobe: module unix not found in modules.dep
mdadm: No arrays found in config file or automatically
Segmentation fault
Waiting for up to 30s for devices to settle...
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
Failed to detect live media
modprobe: module i8042 not found in modules.dep
modprobe: module atkbd not found in modules.dep


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

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


Executing the very same awk command from the initramfs shell (busybox 
ash) afterwards succeeds however:

(initramfs) FINGERED=$(awk -F: '
 $1 == drive name  NF  1 {
 split($2, node,  )
 for (n in node) {
 if (!system(test -b /dev/ node[n]))
 cdrom[i++] = /dev/ node[n]
 }
 }
 END {
 for (c in cdrom)
 print cdrom[c]
 }
 ' /proc/sys/dev/cdrom/info)
(initramfs) echo $FINGERED
/dev/sr0

Likewise rewriting the /proc/sys/dev/cdrom/info parsing to use 
different busybox applets succeeds as well, while using awk in 
different functions (fll_meminfo() and fll_copy_with_perc()) segfaults 
the same way.

 Can you describe your initramfs/environment a bit?  Maybe give me
 access to your initramfs for testing?

I'll provide a link to a test environment in a (private) follow up 
mail, using this live code. While this particular initramfs hook is 
not packaged in Debian, I expect similar issues to arise with standard
Debian initramfs hooks.

  Also, the latest release of busybox, 1.20.1 is a bit different of that, and 
 
 Different of what, exactly?  The version of busybox you're
 filing bugreport against is actually 1.20.1, so there are
 two questions actually: what is different, and different
 between what and what? -- since you're comparing the same
 thing with itself.
[…]

For testing purposes, I've rebuilt busybox (1:1.20.0-4) with only
shell-ash-export-HOME.patch disabled:

--- busybox-1.20.0/debian/patches/series
+++ busybox-1.20.0/debian/patches/series
@@ -1,6 +1,6 @@
 1.20.1.patch
 
-shell-ash-export-HOME.patch
+#shell-ash-export-HOME.patch
 # we need to get rid of this one:
 #applets-fallback.patch
 version.patch

and the segfaults in busybox awk vanished.

Regards
Stefan Lippers-Hollmann

[1] 
http://svn.berlios.de/svnroot/repos/fullstory/fll-live-initramfs/trunk/scripts/fll


signature.asc
Description: This is a digitally signed message part.


Bug#679377: Segmentation fault when initramfs is booting

2012-06-28 Thread Jordi Pujol
Package: busybox
Version: 1:1.20.0-4
Severity: important

the patch shell-ash-export-HOME.patch causes a segmentation fault when 
initramfs boots,
I believe that this fault occurs the first time that initramfs looks for some 
executable in the initramfs filesystem,

Also, the latest release of busybox, 1.20.1 is a bit different of that, and 
more upstream stable patches have been added. A new release can be packaged 
containing this changes,

Modifying this, busybox works fine,

http://livenet.selfip.com/ftp/debian/package-
modifications/busybox_1.20.1-1.lnet1.debian.tar.gz

Kind regards,

Jordi Pujol

Live never ending Tale
GNU/Linux Live forever!
http://livenet.selfip.com



-- 
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/201206281114.23231.jordipuj...@gmail.com