Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Jul 2008 10:35:23 GMT
From:      Mateusz Guzik <mjguzik@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/125257: [jail][patch] Possible memory leak in function jail
Message-ID:  <200807041035.m64AZNhV092444@www.freebsd.org>
Resent-Message-ID: <200807041040.m64Ae1Vd059872@freefall.freebsd.org>

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

>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:



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