NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/41338: ktruss mixes filename arguments
>Number: 41338
>Category: bin
>Synopsis: ktruss mixes filename arguments
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat May 02 17:10:00 +0000 2009
>Originator: Michael van Elst
>Release: NetBSD 5.0
>Organization:
--
Michael van Elst
Internet: mlelstv%serpens.de@localhost
"A potential Snark may lurk in every tree."
>Environment:
System: NetBSD pepew 5.0 NetBSD 5.0 (PEPEW) #2: Sun Apr 26 17:47:22 CEST 2009
mlelstv@henery:/home/netbsd5/obj.i386/home/netbsd5/src/sys/arch/i386/compile/PEPEW
i386
Architecture: i386
Machine: i386
>Description:
ktruss doesn't show systemcalls with the correct filename parameters.
>How-To-Repeat:
Here is a small example,
#include <fcntl.h>
int main()
{
int fd;
fd = open("foo",O_RDONLY,0);
return 0;
}
ktruss for this program yields:
7887 1 ktruss emul(netbsd)
7887 1 ktruss fktrace = 0
7887 1 ktruss fcntl(0x4, 0x3, 0) = 1
7887 1 ktruss fcntl(0x4, 0x4, 0x1) = 0
7887 1 a.out emul(netbsd)
7887 1 a.out execve("./a.out", 0xbfbfe8cc, 0xbfbfe8d4) JUSTRETURN
7887 1 a.out mmap(0, 0x8000, 0x3, 0x1002, 0xffffffff, 0, 0, 0) =
0xbbbea000
7887 1 a.out open("/usr/libexec/ld.elf_so", 0, 0) = 3
7887 1 a.out read(0x3, 0xbfbfe7b8, 0x80) = 55
"libm.so.0\tmachdep.fpu_present\t1:libm387.so.0,libm.so.0\n"
7887 1 a.out close(0x3) = 0
7887 1 a.out open("/etc/ld.so.conf", 0, 0) = 3
7887 1 a.out __fstat30(0x3, 0xbfbfe0d4) = 0
7887 1 a.out mmap(0, 0x1000, 0x1, 0x1, 0x3, 0, 0, 0) = 0xbbbe9000
7887 1 a.out munmap(0xbbbe9000, 0x1000) = 0
7887 1 a.out mmap(0, 0xf0000, 0x5, 0x2, 0x3, 0, 0, 0) = 0xbbafa000
7887 1 a.out mmap(0xbbbd2000, 0x8000, 0x3, 0x12, 0x3, 0, 0xd7000, 0)
= 0xbbbd2000
7887 1 a.out mmap(0xbbbda000, 0x10000, 0x3, 0x1012, 0xffffffff, 0, 0,
0) = 0xbbbda000
7887 1 a.out close(0x3) = 0
7887 1 a.out __sysctl(0xbfbfe7fc, 0x2, 0xbbbe8720, 0xbfbfe804, 0, 0)
= 0
7887 1 a.out open("/usr/lib/libc.so.12", 0, 0) = 3
7887 1 a.out exit(0)
All but the very first filename argument ("./a.out") belongs to a
different system call.
ktrace/kdump for this program yields:
21123 1 ktrace EMUL "netbsd"
21123 1 ktrace RET ktrace 0
21123 1 ktrace CALL execve(0xbfbff9fb,0xbfbfe8cc,0xbfbfe8d4)
21123 1 ktrace NAMI "./a.out"
21123 1 ktrace NAMI "/usr/libexec/ld.elf_so"
21123 1 a.out EMUL "netbsd"
21123 1 a.out RET syscall JUSTRETURN
21123 1 a.out CALL mmap(0,0x8000,3,0x1002,0xffffffff,0,0,0)
21123 1 a.out RET mmap -1145135104/0xbbbea000
21123 1 a.out CALL open(0xbbbfbaed,0,0)
21123 1 a.out NAMI "/etc/ld.so.conf"
21123 1 a.out RET open 3
21123 1 a.out CALL read(3,0xbfbfe7b8,0x80)
21123 1 a.out GIO fd 3 read 55 bytes
"libm.so.0 machdep.fpu_present 1:libm387.so.0,libm.so.0\n"
21123 1 a.out RET read 55/0x37
21123 1 a.out CALL close(3)
21123 1 a.out RET close 0
21123 1 a.out CALL open(0xbfbfe198,0,0)
21123 1 a.out NAMI "/usr/lib/libc.so.12"
21123 1 a.out RET open 3
21123 1 a.out CALL __fstat30(3,0xbfbfe0d4)
21123 1 a.out RET __fstat30 0
21123 1 a.out CALL mmap(0,0x1000,1,1,3,0,0,0)
21123 1 a.out RET mmap -1145139200/0xbbbe9000
21123 1 a.out CALL munmap(0xbbbe9000,0x1000)
21123 1 a.out RET munmap 0
21123 1 a.out CALL mmap(0,0xf0000,5,2,3,0,0,0)
21123 1 a.out RET mmap -1146118144/0xbbafa000
21123 1 a.out CALL mmap(0xbbbd2000,0x8000,3,0x12,3,0,0xd7000,0)
21123 1 a.out RET mmap -1145233408/0xbbbd2000
21123 1 a.out CALL mmap(0xbbbda000,0x10000,3,0x1012,0xffffffff,0,0,0)
21123 1 a.out RET mmap -1145200640/0xbbbda000
21123 1 a.out CALL close(3)
21123 1 a.out RET close 0
21123 1 a.out CALL __sysctl(0xbfbfe7fc,2,0xbbbe8720,0xbfbfe804,0,0)
21123 1 a.out RET __sysctl 0
21123 1 a.out CALL open(0x80487a5,0,0)
21123 1 a.out NAMI "foo"
21123 1 a.out RET open 3
21123 1 a.out CALL exit(0)
>Fix:
In ktruss/dump.c:1.28 a call to flushpendq was commented out. Adding it back
generates correct ktruss output:
3182 1 ktruss emul(netbsd)
3182 1 ktruss fktrace = 0
3182 1 ktruss fcntl(0x4, 0x3, 0) = 1
3182 1 ktruss fcntl(0x4, 0x4, 0x1) = 0
3182 1 a.out emul(netbsd)
3182 1 a.out execve("./a.out", 0xbfbfe8bc, 0xbfbfe8c4) JUSTRETURN
3182 1 a.out mmap(0, 0x8000, 0x3, 0x1002, 0xffffffff, 0, 0, 0) =
0xbbbea000
3182 1 a.out open("/etc/ld.so.conf", 0, 0) = 3
3182 1 a.out read(0x3, 0xbfbfe7b8, 0x80) = 55
"libm.so.0\tmachdep.fpu_present\t1:libm387.so.0,libm.so.0\n"
3182 1 a.out close(0x3) = 0
3182 1 a.out open("/usr/lib/libc.so.12", 0, 0) = 3
3182 1 a.out __fstat30(0x3, 0xbfbfe0d4) = 0
3182 1 a.out mmap(0, 0x1000, 0x1, 0x1, 0x3, 0, 0, 0) = 0xbbbe9000
3182 1 a.out munmap(0xbbbe9000, 0x1000) = 0
3182 1 a.out mmap(0, 0xf0000, 0x5, 0x2, 0x3, 0, 0, 0) = 0xbbafa000
3182 1 a.out mmap(0xbbbd2000, 0x8000, 0x3, 0x12, 0x3, 0, 0xd7000, 0)
= 0xbbbd2000
3182 1 a.out mmap(0xbbbda000, 0x10000, 0x3, 0x1012, 0xffffffff, 0, 0,
0) = 0xbbbda000
3182 1 a.out close(0x3) = 0
3182 1 a.out __sysctl(0xbfbfe7fc, 0x2, 0xbbbe8720, 0xbfbfe804, 0, 0)
= 0
3182 1 a.out open("foo", 0, 0) = 3
3182 1 a.out exit(0)
>Unformatted:
Home |
Main Index |
Thread Index |
Old Index