[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#596382: kfreebsd-image-8.1-1-686: "kern.proc.all" sysctl returns nothing/error. (SOLVED?)


I think I found the problem. The userland code does

          /* find an estimate of how much we need for this var */
          j = 0;
          i = sysctl(oid, nlen, 0, &j, 0, 0);
          j += j; /* we want to be sure :-) */

          val = oval = malloc(j + 1);
          if (val == NULL) {
                  warnx("malloc failed");
                  return (1);
          len = j;
          i = sysctl(oid, nlen, val, &len, 0, 0);
          if (i || !len) {
                  return (1);

with fairly legal arguments:

(gdb) x/2x oid
0xbfbfabd0:     0x00000001      0x0000000e
(gdb) p nlen
$18 = 3
(gdb) p val
$20 = (u_char *) 0x2819c008 <Address 0x2819c008 out of bounds>
(gdb) p len
$21 = 0
(gdb) p j
$22 = 170496

However, inside the kernel vslock() fails with ENOMEM in the following

#0  sysctl_wire_old_buffer (req=0xc88e5ba0, len=0) at ../../../kern/kern_sysctl.c:1289
#1  0xc08da417 in sysctl_kern_proc (oidp=0xc0d97e20, arg1=0x0, arg2=0, req=0xc88e5ba0) at ../../../kern/kern_proc.c:1201
#2  0xc08ef46c in sysctl_root (oidp=<value optimized out>, arg1=0x0, arg2=<value optimized out>, req=0xc88e5ba0) at ../../../kern/kern_sysctl.c:1418
#3  0xc08ef738 in userland_sysctl (td=0xc1e6d000, name=0xc88e5c0c, namelen=3, old=0xbfbec9ef, oldlenp=0xbfbec9e8, inkernel=0, new=0x0, newlen=0, retval=0xc88e5c6c, flags=0) at ../../../kern/kern_sysctl.c:1522
#4  0xc08efbe3 in __sysctl (td=0xc1e6d000, uap=0xc88e5cf8) at ../../../kern/kern_sysctl.c:1448
#5  0xc0bdf0e3 in syscall (frame=0xc88e5d38) at ../../../i386/i386/trap.c:1111
#6  0xc0bc3f50 in Xint0x80_syscall () at ../../../i386/i386/exception.s:261
#7  0xc88e5d38 in ?? ()

This happens since RLIMIT_MEMLOCK is 65536 but you are trying to lock
170496 bytes. If I remove the limit for locked memory everything seems
to work:

# ulimit -l
# sysctl -x kern.proc.all
kern.proc.all: Format:S,proc Length:79104 Dump:0x0003000000000000804459...

Can you please confirm that this works for you too?

Reply to: