Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Dec 2009 23:56:21 GMT
From:      Kevin Day <kevin@your.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/141359: [patch] jls(8) segfault if a jail has more than 6 ipv4 addresses
Message-ID:  <200912102356.nBANuL2S040750@www.freebsd.org>
Resent-Message-ID: <200912110000.nBB00EmJ093002@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         141359
>Category:       bin
>Synopsis:       [patch] jls(8) segfault if a jail has more than 6 ipv4 addresses
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 11 00:00:14 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Kevin Day
>Release:        8.0-RELEASE
>Organization:
Your.Org, Inc.
>Environment:
FreeBSD cs03.your.org 8.0-RELEASE-p1 FreeBSD 8.0-RELEASE-p1 #4: Thu Dec  3 19:11:35 UTC 2009     root@cs03.your.org:/usr/src/sys/amd64/compile/SERVER  amd64
>Description:
If you bind more than 6 ipv4 addresses to a jail, then run jls(8), it segfaults after trying to copy the array of IPs to a single jail.

The crash appears in:

#1  0x000000080064d6c7 in jailparam_get (jp=0x800a02600, njp=5, flags=0) at /usr/src/lib/libjail/jail.c:581

(gdb) list
576                                                 JAIL_ERRMSGLEN);
577                                             return (-1);
578                                     }
579                             }
580                             jiov[ai].iov_base = jp[j].jp_value;
581                             memset(jiov[ai].iov_base, 0, jiov[ai].iov_len);
582                             ai++;
583                     } else if (jp + j != jp_key) {
584                             jiov[i].iov_base = jp[j].jp_name;
585                             jiov[i].iov_len = strlen(jp[j].jp_name) + 1;

It's crashing on memset, because iov_base is null:

(gdb) print jiov[ai]
$1 = {iov_base = 0x0, iov_len = 28}
(gdb) print j
$2 = 1
(gdb) print jp[j]
$3 = {jp_name = 0x800a11040 "ip4.addr", jp_value = 0x0, jp_valuelen = 28, jp_elemlen = 4, jp_ctltype = -1073479675, jp_structtype = 1, jp_flags = 16777216}


>How-To-Repeat:

>Fix:
--- /usr/src/lib/libjail/jail.c.orig    2009-12-10 23:47:06.000000000 +0000
+++ /usr/src/lib/libjail/jail.c 2009-12-10 23:47:39.000000000 +0000
@@ -564,7 +564,8 @@
                if (jp[j].jp_elemlen && !(jp[j].jp_flags & JP_RAWVALUE)) {
                        ai++;
                        jiov[ai].iov_len += jp[j].jp_elemlen * ARRAY_SLOP;
-                       if (jp[j].jp_valuelen >= jiov[ai].iov_len)
+                       if (jp[j].jp_value != NULL && 
+                           jp[j].jp_valuelen >= jiov[ai].iov_len)
                                jiov[ai].iov_len = jp[j].jp_valuelen;
                        else {
                                jp[j].jp_valuelen = jiov[ai].iov_len;


This fixes the crash, and makes jls appear to give the full list of IPs. I'm totally lost trying to follow what this function is doing, so I don't know if this is actually fixing the real bug or just working around the problem. Someone who knows libjail better than I should probably review this.


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912102356.nBANuL2S040750>