Avoiding sysctl at program startup using ELF aux vector (was: concurrent sysctl implementation)

Marius Strobl marius at alchemy.franken.de
Sat Aug 7 13:59:42 UTC 2010


On Fri, Aug 06, 2010 at 02:11:31PM +0300, Kostik Belousov wrote:
> On Fri, Aug 06, 2010 at 01:08:08PM +0200, Marius Strobl wrote:
> > On Fri, Aug 06, 2010 at 12:04:04PM +0300, Kostik Belousov wrote:
> > > On Fri, Aug 06, 2010 at 07:06:33AM +0200, Jeremie Le Hen wrote:
> > > > Hi Kib,
> > > > 
> > > > In-Reply-To: <20100629083901.GG13238 at deviant.kiev.zoral.com.ua>
> > > > On Tue, Jun 29, 2010 at 11:39:01AM +0300, Kostik Belousov wrote:
> > > > > On Tue, Jun 29, 2010 at 10:26:39AM +0200, Marius Strobl wrote:
> > > > > > On Mon, Jun 28, 2010 at 05:48:59PM +0300, Kostik Belousov wrote:
> > > > > > > On Wed, Jun 23, 2010 at 11:09:59PM +0200, Jeremie Le Hen wrote:
> > > > > > > > Hi Kostik,
> > > > > > > > 
> > > > > > > > This patch seems to have faded out from memory.  Is it possible to go
> > > > > > > > forward and commit it?
> > > > > > > I refreshed the patch. Hopefully, nobody will object, and I commit it
> > > > > > > shortly.
> > > > > > > 
> > > > > > > > 
> > > > > > > > Thanks,
> > > > > > > > Regards.
> > > > > > > > 
> > > > > > > > On Sat, Jul 25, 2009 at 12:29:16AM +0300, Kostik Belousov wrote:
> > > > > > > > > Below is the prototype that seems to work for me both with patched and
> > > > > > > > > old rtld on i386. Patch also contains bits for amd64 that I did not
> > > > > > > > > tested yet. All other arches are not buildable for now.
> > > > > > > > > 
> > > > > > > > > Patch completely eliminates sysctl syscalls from the rtld and libc
> > > > > > > > > startup. Without the patch, a single run of /bin/ls did 6 sysctls,
> > > > > > > > > with the patch, no sysctls is queried at all.
> > > > > > > > > 
> > > > > > > Comparing with the originally posted patch, I added support for all
> > > > > > > architectures, tested amd64 and ia32 on amd64, and converted getpagesizes(3)
> > > > > > > that added two more startup sysctls.
> > > > > > > 
> > > > > > > Would be nice to get a testing for at least some !x86 architectures
> > > > > > > before the commit, I added some people who helped me in past, to the Cc:.
> > > > > > > 
> > > > > > 
> > > > > > Doesn't look good on sparc64:
> > > > > > <...>
> > > > > > NFS ROOT: 192.168.1.40:/usr/data/nfsroot/sparc64
> > > > > > dc1: link state changed to UP
> > > > > > pid 24 (ifconfig), uid 0: exited on signal 11
> > > > > > Segmentation fault
> > > > > > Interface  IP-Address  Broadcast
> > > > > > pid 29 (rcorder), uid 0: exited on signal 11
> > > > > > Segmentation fault
> > > > > > pid 30 (grep), uid 0: exited on signal 11
> > > > > > Segmentation fault
> > > > > > pid 31 (rcorder), uid 0: exited on signal 11
> > > > > > Segmentation fault
> > > > > >  
> > > > > > pid 32 (date), uid 0: exited on signal 11
> > > > > > Segmentation fault
> > > > > > Jun 29 12:20:50 getty[36]: open /dev/ttyv3: No such file or directory
> > > > > > <...>
> > > > > > 
> > > > > > Unfortunately, I currently lack the time to debug this.
> > > > > 
> > > > > Thank you.
> > > > 
> > > > Did yu have time to look at this problem?  It would be nice to have this
> > > > in the tree.
> > > 
> > > I cannot move forward without the help from somebody having access to
> > > sparc64 system where the problem is reproducable.
> > 
> > Do you have a debug version of the patch which outputs the necessary
> > information?
> 
> I would suggest to build rtld and libc with debugging symbols and
> get full backtrace from the faults.

v100# gdb /sbin/ifconfig ifconfig.core
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc64-marcel-freebsd"...
Core was generated by `ifconfig'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libbsdxml.so.4...done.
Loaded symbols for /lib/libbsdxml.so.4
Reading symbols from /lib/libjail.so.1...done.
Loaded symbols for /lib/libjail.so.1
Reading symbols from /lib/libsbuf.so.5...done.
Loaded symbols for /lib/libsbuf.so.5
Reading symbols from /lib/libipx.so.5...done.
Loaded symbols for /lib/libipx.so.5
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x000000004089ebdc in getpagesizes (pagesize=0x7fdffffe2f8, nelem=1)
    at /usr/home/marius/co/head/src/lib/libc/gen/getpagesizes.c:75
75                      while (nops > 0 && ps[nops - 1] == 0)
(gdb) bt
#0  0x000000004089ebdc in getpagesizes (pagesize=0x7fdffffe2f8, nelem=1)
    at /usr/home/marius/co/head/src/lib/libc/gen/getpagesizes.c:75
#1  0x00000000407f4314 in malloc_init ()
    at /usr/home/marius/co/head/src/lib/libc/stdlib/malloc.c:5418
#2  0x00000000407f67d8 in malloc (size=32)
    at /usr/home/marius/co/head/src/lib/libc/stdlib/malloc.c:5932
#3  0x00000000001069ac in clone_setdefcallback (ifprefix=0x11b8a8 "wlan", 
    p=0x10a1a0 <wlan_create>)
    at /usr/home/marius/co/head/src/sbin/ifconfig/ifclone.c:106
#4  0x0000000000119864 in __do_global_ctors_aux ()
#5  0x000000000010243c in _init ()
#6  0x0000000000102508 in _start ()
#7  0x000000004022719c in .rtld_start ()
    at /usr/home/marius/co/head/src/libexec/rtld-elf/sparc64/rtld_start.S:59
#8  0x000000004022719c in .rtld_start ()
    at /usr/home/marius/co/head/src/libexec/rtld-elf/sparc64/rtld_start.S:59
Previous frame identical to this frame (corrupt stack?)

All faults I've looked at died the same why.

Marius



More information about the freebsd-hackers mailing list