start-stop-daemon broke on linus tree
Denys Vlasenko
vda.linux at googlemail.com
Wed Apr 16 18:46:56 UTC 2008
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 */
}
>
> ------ Kernel list mail ---
>
> root at localhost:~# start-stop-daemon --stop --name eq_ppp_mgr
> start-stop-daemon: lseek: Invalid argument
>
> root at localhost:~# strace start-stop-daemon --stop --name eq_ppp_mgr
> execve("/sbin/start-stop-daemon", ["start-stop-daemon", "--stop", "--name", "eq_ppp_mgr"], [/* 12 vars */]) = 0
> uname({sys="Linux", node="localhost.localdomain", ...}) = 0
> brk(0) = 0x1007c000
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x48017000
> access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
> open("/opt/appl/executing/lib/tls/ppc603/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/opt/appl/executing/lib/tls/ppc603", 0xbfb940a0) = -1 ENOENT (No such file or directory)
> open("/opt/appl/executing/lib/tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/opt/appl/executing/lib/tls", 0xbfb940a0) = -1 ENOENT (No such file or directory)
> open("/opt/appl/executing/lib/ppc603/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/opt/appl/executing/lib/ppc603", 0xbfb940a0) = -1 ENOENT (No such file or directory)
> open("/opt/appl/executing/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/opt/appl/executing/lib", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
> open("/opt/appl/started/lib/tls/ppc603/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/opt/appl/started/lib/tls/ppc603", 0xbfb940a0) = -1 ENOENT (No such file or directory)
> open("/opt/appl/started/lib/tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/opt/appl/started/lib/tls", 0xbfb940a0) = -1 ENOENT (No such file or directory)
> open("/opt/appl/started/lib/ppc603/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/opt/appl/started/lib/ppc603", 0xbfb940a0) = -1 ENOENT (No such file or directory)
> open("/opt/appl/started/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/opt/appl/started/lib", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
> open("/opt/appl/next/lib/tls/ppc603/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/opt/appl/next/lib/tls/ppc603", 0xbfb940a0) = -1 ENOENT (No such file or directory)
> open("/opt/appl/next/lib/tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/opt/appl/next/lib/tls", 0xbfb940a0) = -1 ENOENT (No such file or directory)
> open("/opt/appl/next/lib/ppc603/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/opt/appl/next/lib/ppc603", 0xbfb940a0) = -1 ENOENT (No such file or directory)
> open("/opt/appl/next/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/opt/appl/next/lib", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
> open("/etc/ld.so.cache", O_RDONLY) = 3
> fstat64(3, {st_mode=S_IFREG|0644, st_size=64, ...}) = 0
> mmap(NULL, 64, PROT_READ, MAP_PRIVATE, 3, 0) = 0x48018000
> close(3) = 0
> open("/lib/tls/ppc603/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/lib/tls/ppc603", 0xbfb940a0) = -1 ENOENT (No such file or directory)
> open("/lib/tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/lib/tls", 0xbfb940a0) = -1 ENOENT (No such file or directory)
> open("/lib/ppc603/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
> stat64("/lib/ppc603", 0xbfb940a0) = -1 ENOENT (No such file or directory)
> open("/lib/libc.so.6", O_RDONLY) = 3
> read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\1\314"..., 512) = 512
> fstat64(3, {st_mode=S_IFREG|0755, st_size=1345728, ...}) = 0
> mmap(0xfea7000, 1346452, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xfea7000
> madvise(0xfea7000, 1346452, MADV_SEQUENTIAL|0x1) = 0
> mprotect(0xffd8000, 97172, PROT_NONE) = 0
> mmap(0xffe8000, 24576, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x131000) = 0xffe8000
> mmap(0xffee000, 7060, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffee000
> close(3) = 0
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x48019000
> mprotect(0xffe8000, 8192, PROT_READ) = 0
> mprotect(0x48026000, 4096, PROT_READ) = 0
> munmap(0x48018000, 64) = 0
> open("/dev/urandom", O_RDONLY) = 3
> read(3, "a\25\24G", 4) = 4
> close(3) = 0
> getuid() = 0
> open("/proc", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 3
> fstat64(3, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
> fcntl64(3, F_SETFD, FD_CLOEXEC) = 0
> brk(0) = 0x1007c000
> brk(0x1009d000) = 0x1009d000
> getdents64(3, /* 35 entries */, 1024) = 1024
> getdents64(3, /* 40 entries */, 1024) = 1024
> open("/proc/1/stat", O_RDONLY|O_LARGEFILE) = 4
> _llseek(4, 0, 0xbfb94898, SEEK_END) = -1 EINVAL (Invalid argument)
> write(2, "start-stop-daemon: lseek: Invali"..., 43start-stop-daemon: lseek: Invalid argument
> ) = 43
> exit_group(1) = ?
> Process 555 detached
>
>
> So it appears that lseek is no longer allowed for /proc/1/stat
> Bug or feature?
> start-stop-daemon works fine in 2.6.23
>
> Jocke
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
>
More information about the busybox
mailing list