From owner-freebsd-bugs@FreeBSD.ORG Fri Jul 4 10:40:02 2008 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 4C823106566C for ; Fri, 4 Jul 2008 10:40:02 +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 0F30E8FC30 for ; Fri, 4 Jul 2008 10:40:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m64Ae1DT059880 for ; Fri, 4 Jul 2008 10:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m64Ae1Vd059872; Fri, 4 Jul 2008 10:40:01 GMT (envelope-from gnats) Resent-Date: Fri, 4 Jul 2008 10:40:01 GMT Resent-Message-Id: <200807041040.m64Ae1Vd059872@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, Mateusz Guzik Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A1B3106566C for ; Fri, 4 Jul 2008 10:35:24 +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 3878D8FC2C for ; Fri, 4 Jul 2008 10:35:24 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m64AZNu6092445 for ; Fri, 4 Jul 2008 10:35:23 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m64AZNhV092444; Fri, 4 Jul 2008 10:35:23 GMT (envelope-from nobody) Message-Id: <200807041035.m64AZNhV092444@www.freebsd.org> Date: Fri, 4 Jul 2008 10:35:23 GMT From: Mateusz Guzik To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/125257: [jail][patch] Possible memory leak in function jail 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, 04 Jul 2008 10:40:02 -0000 >Number: 125257 >Category: kern >Synopsis: [jail][patch] Possible memory leak in function jail >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jul 04 10:40:01 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Mateusz Guzik >Release: 8.0-CURRENT >Organization: >Environment: FreeBSD eternal 8.0-CURRENT FreeBSD 8.0-CURRENT #12: Fri Jul 4 12:16:30 CEST 2008 f@eternal:/usr/obj/usr/src/sys/ETERNAL i386 >Description: Line 164 of sys/kern/kern_jail.c (rev 1.78) looks like this: pr->pr_slots = malloc(sizeof(*pr->pr_slots) * prison_service_slots, M_PRISON, M_ZERO | M_WAITOK); But in case of failure, memmory allocated for pr->pr_slots is not freed. (Lines starting at 215.) >How-To-Repeat: >Fix: Patch attached with submission follows: --- sys/kern/kern_jail.c.orig 2008-07-04 12:11:43.000000000 +0200 +++ sys/kern/kern_jail.c 2008-07-04 12:33:45.000000000 +0200 @@ -212,10 +212,12 @@ vfslocked = VFS_LOCK_GIANT(pr->pr_root->v_mount); vrele(pr->pr_root); VFS_UNLOCK_GIANT(vfslocked); e_killmtx: mtx_destroy(&pr->pr_mtx); + if (pr->pr_slots != NULL) + FREE(pr->pr_slots, M_PRISON); FREE(pr, M_PRISON); return (error); } /* >Release-Note: >Audit-Trail: >Unformatted: