From owner-svn-src-head@freebsd.org Tue Jul 14 18:24:06 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 79F829A18BA; Tue, 14 Jul 2015 18:24:06 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6AB3EFAF; Tue, 14 Jul 2015 18:24:06 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6EIO6Wv056211; Tue, 14 Jul 2015 18:24:06 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6EIO6At056210; Tue, 14 Jul 2015 18:24:06 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201507141824.t6EIO6At056210@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 14 Jul 2015 18:24:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285548 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jul 2015 18:24:06 -0000 Author: markj Date: Tue Jul 14 18:24:05 2015 New Revision: 285548 URL: https://svnweb.freebsd.org/changeset/base/285548 Log: Fix some error-handling bugs when core dump compression is enabled: - Ensure that core dump parameters are initialized in the error path. - Don't call gzio_fini() on a NULL stream. Reported by: rpaulo Modified: head/sys/kern/imgact_elf.c Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Tue Jul 14 17:01:55 2015 (r285547) +++ head/sys/kern/imgact_elf.c Tue Jul 14 18:24:05 2015 (r285548) @@ -1241,6 +1241,7 @@ __elfN(coredump)(struct thread *td, stru compress = (flags & IMGACT_CORE_COMPRESS) != 0; hdr = NULL; + tmpbuf = NULL; TAILQ_INIT(¬elst); /* Size the program segments. */ @@ -1255,6 +1256,14 @@ __elfN(coredump)(struct thread *td, stru __elfN(prepare_notes)(td, ¬elst, ¬esz); coresize = round_page(hdrsize + notesz) + seginfo.size; + /* Set up core dump parameters. */ + params.offset = 0; + params.active_cred = cred; + params.file_cred = NOCRED; + params.td = td; + params.vp = vp; + params.gzs = NULL; + #ifdef RACCT if (racct_enable) { PROC_LOCK(td->td_proc); @@ -1271,15 +1280,6 @@ __elfN(coredump)(struct thread *td, stru goto done; } - /* Set up core dump parameters. */ - params.offset = 0; - params.active_cred = cred; - params.file_cred = NOCRED; - params.td = td; - params.vp = vp; - params.gzs = NULL; - - tmpbuf = NULL; #ifdef GZIO /* Create a compression stream if necessary. */ if (compress) { @@ -1336,7 +1336,8 @@ done: #ifdef GZIO if (compress) { free(tmpbuf, M_TEMP); - gzio_fini(params.gzs); + if (params.gzs != NULL) + gzio_fini(params.gzs); } #endif while ((ninfo = TAILQ_FIRST(¬elst)) != NULL) {