From owner-freebsd-current@FreeBSD.ORG Sat Apr 17 01:16:14 2010 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B0CB106564A for ; Sat, 17 Apr 2010 01:16:14 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 5FCF58FC12 for ; Sat, 17 Apr 2010 01:16:14 +0000 (UTC) Received: by elvis.mu.org (Postfix, from userid 1192) id 1B9471A3C66; Fri, 16 Apr 2010 18:16:14 -0700 (PDT) Date: Fri, 16 Apr 2010 18:16:14 -0700 From: Alfred Perlstein To: current@freebsd.org Message-ID: <20100417011614.GR54028@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Cc: Subject: fix for compressed coredumps, please review X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Apr 2010 01:16:14 -0000 Can I get a review for this? summary: If doing compressed cores and there is an error, we leak resources unless this is fixed. Index: imgact_elf.c =================================================================== --- imgact_elf.c (revision 206498) +++ imgact_elf.c (working copy) @@ -29,7 +29,7 @@ */ #include -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: head/sys/kern/imgact_elf.c 205643 2010-03-25 14:31:26Z nwhitehorn $"); #include "opt_compat.h" #include "opt_core.h" @@ -1088,8 +1088,10 @@ hdrsize = 0; __elfN(puthdr)(td, (void *)NULL, &hdrsize, seginfo.count); - if (hdrsize + seginfo.size >= limit) - return (EFAULT); + if (hdrsize + seginfo.size >= limit) { + error = EFAULT; + goto done; + } /* * Allocate memory for building the header, fill it up, @@ -1097,7 +1099,8 @@ */ hdr = malloc(hdrsize, M_TEMP, M_WAITOK); if (hdr == NULL) { - return (EINVAL); + error = EINVAL; + goto done; } error = __elfN(corehdr)(td, vp, cred, seginfo.count, hdr, hdrsize, gzfile); @@ -1125,8 +1128,8 @@ curproc->p_comm, error); } +done: #ifdef COMPRESS_USER_CORES -done: if (core_buf) free(core_buf, M_TEMP); if (gzfile) -- - Alfred Perlstein .- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250 .- FreeBSD committer