FreeBSD 1.x Binaries Work Except under Chroot
Dan Plassche
dplassche at gmail.com
Fri Aug 10 21:15:35 UTC 2012
On Fri, Aug 10, 2012 at 1:07 PM, Konstantin Belousov
<kostikbel at gmail.com> wrote:
> Try to ktrace the binaries to see what is going on. I suspect that
> sources for 1.1.5 are not in our cvs/svn, so it is troublesome to
> say anuthing without ktrace dump.
Ok, below is the kdump from running basename as a simple example
that produces the "ld.so: whereis: libc.so.1.1" error under a
chrooted environment.
I probably should have mentioned that I'm running these with
"sysctl security.bsd.map_at_zero=1" set. The static binaries
in /bin and /sbin also work under the chroot, but the others in
/usr/bin and /usr/sbin fail with the ld.so error.
Here's the kdump:
1144 ktrace-8.2 RET ktrace 0
1144 ktrace-8.2 CALL execve(0xbfbfee5b,0xbfbfed18,0xbfbfed20)
1144 ktrace-8.2 NAMI "/usr/bin/basename"
1144 basename RET execve 0
1144 basename CALL open(0x10a4,O_RDONLY,<unused>0)
1144 basename NAMI "/usr/libexec/ld.so"
1144 basename RET open 3
1144 basename CALL read(0x3,0xbfbfedd8,0x20)
1144 basename GIO fd 3 read 32 bytes
0x0000 cc00 8680 00d0 0000 0020 0000 8003 0000 |......... ......|
0x0010 0000 0000 2000 0000 0000 0000 0000 0000 |.... ...........|
1144 basename RET read 32/0x20
1144 basename CALL compat.mmap(0,0xd000,0x5,0x21,0x3,0)
1144 basename RET compat.mmap 536879104/0x20002000
1144 basename CALL compat.mmap(0x2000f000,0x2000,0x6,0x121,0x3,0xd000)
1144 basename RET compat.mmap 536932352/0x2000f000
1144 basename CALL compat.mmap(0x20011000,0x380,0x6,0x122,0xffffffff,0)
1144 basename RET compat.mmap 536940544/0x20011000
1144 basename CALL getuid
1144 basename RET getuid 0
1144 basename CALL geteuid
1144 basename RET geteuid 0
1144 basename CALL getgid
1144 basename RET getgid 0
1144 basename CALL getegid
1144 basename RET getegid 0
1144 basename CALL compat.mmap(0,0x8000,0x6,0x22,0xffffffff,0)
1144 basename RET compat.mmap 536944640/0x20012000
1144 basename CALL open(0x200032b0,O_RDONLY,<unused>0)
1144 basename NAMI "/var/run/ld.so.hints"
1144 basename RET open 4
1144 basename CALL compat.mmap(0,0x1000,0x4,0x21,0x4,0)
1144 basename RET compat.mmap 536977408/0x2001a000
1144 basename CALL munmap(0x2001a000,0x1000)
1144 basename RET munmap 0
1144 basename CALL open(0x20014000,O_RDONLY,<unused>0x2000f060)
1144 basename NAMI "/usr/lib"
1144 basename RET open 5
1144 basename CALL fcntl(0x5,F_SETFD,FD_CLOEXEC)
1144 basename RET fcntl 0
1144 basename CALL compat.getdirentries(0x5,0x20017000,0x400,0x200150f4)
1144 basename RET compat.getdirentries 1024/0x400
1144 basename CALL compat.getdirentries(0x5,0x20017000,0x400,0x200150f4)
1144 basename RET compat.getdirentries 512/0x200
1144 basename CALL compat.getdirentries(0x5,0x20017000,0x400,0x200150f4)
1144 basename RET compat.getdirentries 0
1144 basename CALL close(0x5)
1144 basename RET close 0
1144 basename CALL open(0x20015000,O_RDONLY,<unused>0x2000f060)
1144 basename NAMI "/usr/X11R6/lib"
1144 basename RET open -1 errno 2 No such file or directory
1144 basename CALL open(0x20015020,O_RDONLY,<unused>0x2000f060)
1144 basename NAMI "/usr/X386/lib"
1144 basename RET open -1 errno 2 No such file or directory
1144 basename CALL open(0x20015060,O_RDONLY,<unused>0x2000f060)
1144 basename NAMI "/usr/local/lib"
1144 basename RET open 5
1144 basename CALL fcntl(0x5,F_SETFD,FD_CLOEXEC)
1144 basename RET fcntl 0
1144 basename CALL compat.getdirentries(0x5,0x20017000,0x400,0x200150f4)
1144 basename RET compat.getdirentries 512/0x200
1144 basename CALL compat.getdirentries(0x5,0x20017000,0x400,0x200150f4)
1144 basename RET compat.getdirentries 0
1144 basename CALL close(0x5)
1144 basename RET close 0
1144 basename CALL open(0x20015100,O_RDONLY,<unused>0)
1144 basename NAMI "/usr/lib/libgcc.so.1.1"
1144 basename RET open 5
1144 basename CALL read(0x5,0xbfbfed40,0x20)
1144 basename GIO fd 5 read 32 bytes
0x0000 cc00 8680 0030 0000 0010 0000 0000 0000 |.....0..........|
0x0010 600f 0000 2000 0000 0000 0000 0000 0000 |`... ...........|
1144 basename RET read 32/0x20
1144 basename CALL compat.mmap(0,0x4000,0x5,0x21,0x5,0)
1144 basename RET compat.mmap 536977408/0x2001a000
1144 basename CALL mprotect(0x2001d000,0x1000,PROT_READ|PROT_WRITE|PROT_EXEC)
1144 basename RET mprotect 0
1144 basename CALL close(0x5)
1144 basename RET close 0
1144 basename CALL open(0x20014000,O_RDONLY,<unused>0x2000f060)
1144 basename NAMI "/usr/lib"
1144 basename RET open 5
1144 basename CALL fcntl(0x5,F_SETFD,FD_CLOEXEC)
1144 basename RET fcntl 0
1144 basename CALL compat.getdirentries(0x5,0x20017000,0x400,0x20015154)
1144 basename RET compat.getdirentries 1024/0x400
1144 basename CALL compat.getdirentries(0x5,0x20017000,0x400,0x20015154)
1144 basename RET compat.getdirentries 512/0x200
1144 basename CALL compat.getdirentries(0x5,0x20017000,0x400,0x20015154)
1144 basename RET compat.getdirentries 0
1144 basename CALL close(0x5)
1144 basename RET close 0
1144 basename CALL open(0x20015000,O_RDONLY,<unused>0x2000f060)
1144 basename NAMI "/usr/X11R6/lib"
1144 basename RET open -1 errno 2 No such file or directory
1144 basename CALL open(0x20015020,O_RDONLY,<unused>0x2000f060)
1144 basename NAMI "/usr/X386/lib"
1144 basename RET open -1 errno 2 No such file or directory
1144 basename CALL open(0x20015060,O_RDONLY,<unused>0x2000f060)
1144 basename NAMI "/usr/local/lib"
1144 basename RET open 5
1144 basename CALL fcntl(0x5,F_SETFD,FD_CLOEXEC)
1144 basename RET fcntl 0
1144 basename CALL compat.getdirentries(0x5,0x20017000,0x400,0x20015154)
1144 basename RET compat.getdirentries 512/0x200
1144 basename CALL compat.getdirentries(0x5,0x20017000,0x400,0x20015154)
1144 basename RET compat.getdirentries 0
1144 basename CALL close(0x5)
1144 basename RET close 0
1144 basename CALL open(0x20015160,O_RDONLY,<unused>0)
1144 basename NAMI "/usr/lib/libc.so.1.1"
1144 basename RET open 5
1144 basename CALL read(0x5,0xbfbfed40,0x20)
1144 basename GIO fd 5 read 32 bytes
0x0000 cc00 8680 0070 0400 0060 0000 b86b 0000 |.....p...`...k..|
0x0010 b4b7 0000 2000 0000 0000 0000 0000 0000 |.... ...........|
1144 basename RET read 32/0x20
1144 basename CALL compat.mmap(0,0x4d000,0x5,0x21,0x5,0)
1144 basename RET compat.mmap 536993792/0x2001e000
1144 basename CALL mprotect(0x20065000,0x6000,PROT_READ|PROT_WRITE|PROT_EXEC)
1144 basename RET mprotect 0
1144 basename CALL close(0x5)
1144 basename RET close 0
1144 basename CALL
compat.mmap(0x2006b000,0x6bb8,0x7,0x122,0xffffffff,0x4d000)
1144 basename RET compat.mmap -1 errno 22 Invalid argument
1144 basename CALL write(0x2,0xbfbfe5fc,0x7)
1144 basename GIO fd 2 wrote 7 bytes
"ld.so: "
1144 basename RET write 7
1144 basename CALL write(0x2,0xbfbfe614,0x15)
1144 basename GIO fd 2 wrote 21 bytes
"basename: libc.so.1.1"
1144 basename RET write 21/0x15
1144 basename CALL write(0x2,0xbfbfe5f4,0x2)
1144 basename GIO fd 2 wrote 2 bytes
": "
1144 basename RET write 2
1144 basename CALL write(0x2,0xbfbfe5f8,0x11)
1144 basename GIO fd 2 wrote 17 bytes
"Invalid argument
"
1144 basename RET write 17/0x11
1144 basename CALL exit(0x1)
The sources are available from the FreeBSD old releases archive
now that they are under the "Ancient UNIX" license, but yeah
there's no CVS history for change tracking due to the purge
with the switch to 4.4 Lite.
Thanks,
Dan
More information about the freebsd-hackers
mailing list