From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 10 21:15:35 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 861CB106566B for ; Fri, 10 Aug 2012 21:15:35 +0000 (UTC) (envelope-from dplassche@gmail.com) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by mx1.freebsd.org (Postfix) with ESMTP id 1448A8FC0C for ; Fri, 10 Aug 2012 21:15:34 +0000 (UTC) Received: by wibhq12 with SMTP id hq12so1485399wib.1 for ; Fri, 10 Aug 2012 14:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ocd31dIX67j33wtpWzUfvmAzvYU7+yJTjZg3RqQS8WE=; b=0Yuowd5skMpl6nCSRYaiAZyXqt/HcX166IkakqDAYwDieLGa3CbY1J2qMlzdKBxCE4 9o0FqJ65LXnR53LW6c0v7cnBNYyaFWhXJQA56AeTXCwvlagVt3POgskmnmQlEWMDzhZG 9Qe2seJ2ZBQHVfmFuvJfZdtXYRKAY8r/VyYcLYRvYjr1RLPTGi3cLr3tmAynykwUC4sj uW4crE1L30Qdo9f+k2Yw2c5bQJueVOV4l/RGnqcRlRW7yMB5x6z6dAy6kyM3hm6qw6rH 5BTq8c9ayNPEjr27eX0F9h73oA6DGDVEKW53PuyI2jXbSQ4BYUeuPQ9w9s1trjX5+YOg sHvQ== MIME-Version: 1.0 Received: by 10.217.1.197 with SMTP id n47mr2180921wes.27.1344633333784; Fri, 10 Aug 2012 14:15:33 -0700 (PDT) Received: by 10.223.134.7 with HTTP; Fri, 10 Aug 2012 14:15:33 -0700 (PDT) In-Reply-To: References: <20120810170715.GI2425@deviant.kiev.zoral.com.ua> Date: Fri, 10 Aug 2012 17:15:33 -0400 Message-ID: From: Dan Plassche To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Mailman-Approved-At: Sat, 11 Aug 2012 00:09:02 +0000 Subject: Re: FreeBSD 1.x Binaries Work Except under Chroot X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2012 21:15:35 -0000 On Fri, Aug 10, 2012 at 1:07 PM, Konstantin Belousov 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,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,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,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,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,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,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,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,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,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,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,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,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