start-stop-daemon broke on linus tree

Joakim Tjernlund Joakim.Tjernlund at transmode.se
Wed Apr 16 19:01:30 UTC 2008


> -----Original Message-----
> From: Denys Vlasenko [mailto:vda.linux at googlemail.com]
> Sent: den 16 april 2008 20:47
> To: busybox at busybox.net; joakim.tjernlund at transmode.se
> Subject: Re: start-stop-daemon broke on linus tree
> 
> On Wednesday 16 April 2008 19:56, Joakim Tjernlund wrote:
> > Just sent this to the kernel list, figured you might want a copy too,
> > see last in this mail. One more note, stracing
> >  strace -s 120 start-stop-daemon --stop --exec /opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbear
> > shows alot of
> >  readlink("/proc/371/exe", "/opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit", 49) = 49
> >  readlink("/proc/373/exe", "/opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit", 49) = 49
> >  readlink("/proc/375/exe", "/opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit", 49) = 49
> >  readlink("/proc/411/exe", "/opt/appl/cuappl02a-r11a-080416jt2/bin/dropbearmu", 49) = 49
> >
> > 49 bytes seems a little short, we have longer path names than 49 bytes.
> 
> Not really. strlen("/opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbear") = 48.
> We can safely read 48+1 byte only if we only want to know whether it is
> equal to that or not:
> 
> static int pid_is_exec(pid_t pid, const char *name)
> {
>         char buf[sizeof("/proc//exe") + sizeof(int)*3];
>         char *execbuf;
>         int n;
> 
>         sprintf(buf, "/proc/%u/exe", pid);
>         n = strlen(name) + 1;
>         execbuf = xzalloc(n + 1);
>         readlink(buf, execbuf, n);
>         /* if readlink fails because link target is longer than strlen(name),
>          * execbuf still contains "", and strcmp will return !0. */
>         n = strcmp(execbuf, name);
>         if (ENABLE_FEATURE_CLEAN_UP)
>                 free(execbuf);
>         return !n; /* nonzero (true) if execbuf == name */
> }

I see, stupid me not realizing that bb only reads as much as it need.

Seems like my LKML mail didn't make it. I guess it is due to
our mail server at work just got blacklisted :(

   Jocke




More information about the busybox mailing list