Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 11 Feb 2023 09:01:03 -0500
From: Rich Felker <dalias@...c.org>
To: Bastian Bittorf <bb@....de>
Cc: musl@...ts.openwall.com, mailinglist <openwrt-devel@...ts.openwrt.org>
Subject: Re: busybox problem on powerpc PPC/32bit (hardware
 TP-Link-WDR-4900-v1)

On Sat, Feb 11, 2023 at 12:51:47PM +0000, Bastian Bittorf wrote:
> With OpenWRT i recognized a strange behavior of ash-shell scripts.
> It happens only on target PowerPC, e.g. m68k, arm, mips, x86 are
> unaffected.
> 
> The visible strange behavior in 'ash' is:
> 
> $ test A -gt 5 && echo OK
> ash: A: out of range
> OK
> 
> Ofcourse this wrong returncode leads to all sorts of things...
> 
> I tested several busybox releases (1.33.2, 1.35.0, 1.36.0) and
> crosscompiled with musl-git-b76f37f (from musl.cc) and 
> crosscompiled with glibc: powerpc-linux-gnu-gcc (Debian-12.2.0)
> (it's the same for all versions)
> 
> The resulting linux + busybox images ready for QEMU are here:
> http://intercity-vpn.de/mpc85xx/
> 
> If needed i can provide build instructions.
> Maybe somebody with more powerpc assembly knowledge can help here.
> 
> The underlying code is here:  
> https://git.busybox.net/busybox/tree/coreutils/test.c#n488
> But i can not spot the error:
> 
> static number_t getn(const char *s)
> {
>   char *p;
>   errno = 0;
>   r = strtol(s, &p, 10);
>   if (errno != 0)
>     syntax(s, "out of range");
>   return r;
> }
> 
> Best Greetings,
> Bastian Bittorf

It looks like the powerpc spe longjmp code is clobbering the value
argument. Try the attached patch.

View attachment "ppc-spe-longjmp-fix.diff" of type "text/plain" (447 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.