From owner-freebsd-bugs@FreeBSD.ORG Fri Dec 11 00:00:16 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 82F62106566C for ; Fri, 11 Dec 2009 00:00:14 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B1E108FC15 for ; Fri, 11 Dec 2009 00:00:14 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nBB00ENE093005 for ; Fri, 11 Dec 2009 00:00:14 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id nBB00EmJ093002; Fri, 11 Dec 2009 00:00:14 GMT (envelope-from gnats) Resent-Date: Fri, 11 Dec 2009 00:00:14 GMT Resent-Message-Id: <200912110000.nBB00EmJ093002@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Kevin Day Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9350E106566B for ; Thu, 10 Dec 2009 23:56:22 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 683DD8FC12 for ; Thu, 10 Dec 2009 23:56:22 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id nBANuMdc040768 for ; Thu, 10 Dec 2009 23:56:22 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id nBANuL2S040750; Thu, 10 Dec 2009 23:56:21 GMT (envelope-from nobody) Message-Id: <200912102356.nBANuL2S040750@www.freebsd.org> Date: Thu, 10 Dec 2009 23:56:21 GMT From: Kevin Day To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/141359: [patch] jls(8) segfault if a jail has more than 6 ipv4 addresses X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Dec 2009 00:00:16 -0000 >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: