ls -l segfault + [PATCH]

Jan Evert van Grootheest Jan-Evert.van.Grootheest at Vialis.nl
Mon Mar 19 12:44:55 UTC 2007


> > > On Mon, Mar 19, 2007 at 08:26:46AM +0100, Jan Evert van 
> Grootheest 
> > > wrote:
> > > > Hmm, it crashes for me also with ls -la /bin...
> > > > And it doesn't crash in strace (or gdb) here too.
> > > 
> > > Busybox has a feature that allows calling applet_main() 
> instead of 
> > > exec(self, applet, args...). It might be that there's 
> some changed 
> > > data that causes the SEGV.
> > > 
> > > Change the function is_safe_applet, in shell/ash.c, to 
> always return 
> > > false (0), and check if the SEGV disappears.
> > 
> > With return 0 at the top of is_safe_applet, ls works just fine.
> > 
> > So I guess there's a difference in libc where setvbuf does
> > something weird... I already worked up a small testprogram 
> > that failed to show the issue, but I'll now add a fork to it. 
> > The main difference here, I think, is the program state? A 
> > newly exec-ed process vs. The history of the parent.
> 
> It is reproducable with this small test program.
> Leave out the fork or the first printf and things work.

Even the fork is unneeded; just using printf before the setvbuf is enough.
And the manual page says:
------------ quote man setvbuf ------------
The setvbuf() function may only be used after opening a stream and before any other operations have been performed on it.
------------ endquote ---------------------

So the patch below would be one possible solution.

-- Jan Evert


--- ash.c.org   Mon Mar 19 13:43:10 2007
+++ ash.c       Mon Mar 19 13:43:21 2007
@@ -2049,7 +2049,6 @@ static int is_safe_applet(char *name)
                USE_FIND   (, "find"   )
                USE_HEXDUMP(, "hexdump")
                USE_LN     (, "ln"     )
-               USE_LS     (, "ls"     )
                USE_MKDIR  (, "mkdir"  )
                USE_RM     (, "rm"     )
                USE_SORT   (, "sort"   ) 
 
The information contained in this communication is confidential and may be legally privileged. It is intended solely for the use of the individual or entity to whom it is addressed and others authorised to receive it. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful. Vialis is neither liable for the proper and complete transmission of the information contained in this communication nor for any delay in its receipt. 
 



More information about the busybox mailing list