From owner-svn-src-all@FreeBSD.ORG Thu Oct 23 23:21:39 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6AAA6998; Thu, 23 Oct 2014 23:21:39 +0000 (UTC) Received: from mail-wi0-x232.google.com (mail-wi0-x232.google.com [IPv6:2a00:1450:400c:c05::232]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7BB2E128; Thu, 23 Oct 2014 23:21:38 +0000 (UTC) Received: by mail-wi0-f178.google.com with SMTP id q5so58175wiv.17 for ; Thu, 23 Oct 2014 16:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=gOjDjSZv/BoE3yO/hSVF785WlGnHPFhm4pbLOTwpMxE=; b=YTKEf6u2B9toWU2kAIMw8/cUzrFmQGJhJZmuA1cqPxbi8Lh5TPcuM3zKkAbmcaCIli GXL0evYYHESxkQ1eKZVDt1nO9HTM3KCb2+8YTgEs8SOw9CnJ34i06Zn5wexckplI2atw zUWJ2ifJIiFiB2ttEJTfmX7MZtSK0aOYUBPS5UGbtlwPzCJhOpwCQIHaAFIHeri0RLwV L3Jl9xpGv+AZVVYJqwJmwJYVN/j1BfZwKgl3sKSE7VPvsKjmvEpyKVd4Pr/affTyqp/I WgIJXclhnMsf+jMbdnSPktNL8dORNyeGrop0DONiA0dSuShSG4rIoPMmBLY7gtlu9SOu 5YhQ== X-Received: by 10.180.90.230 with SMTP id bz6mr131404wib.67.1414106496819; Thu, 23 Oct 2014 16:21:36 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id ei1sm98378wib.20.2014.10.23.16.21.35 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 23 Oct 2014 16:21:35 -0700 (PDT) Date: Fri, 24 Oct 2014 01:21:33 +0200 From: Mateusz Guzik To: d@delphij.net Subject: Re: svn commit: r273552 - head/sys/kern Message-ID: <20141023232133.GA11222@dft-labs.eu> References: <201410231823.s9NINpXD082633@svn.freebsd.org> <86egtyz9mz.fsf@nine.des.no> <54498CE9.1090000@delphij.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <54498CE9.1090000@delphij.net> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, Dag-Erling =?utf-8?B?U23DuHJncmF2?= , svn-src-all@freebsd.org, src-committers@freebsd.org, Xin LI X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Oct 2014 23:21:39 -0000 On Thu, Oct 23, 2014 at 04:19:05PM -0700, Xin Li wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > On 10/23/14 15:47, Dag-Erling Smørgrav wrote: > > Xin LI writes: > >> Log: Test if 'env' is NULL before doing memset() and strlen(), > >> the caller may pass NULL to freeenv(). > > > > If this is in response to a panic in early boot, the real bug is > > elsewhere (see r273564). Adding a NULL check here only hides it. > > Yes that would fix it. Does this look good to you? > > Index: sys/kern/kern_environment.c > =================================================================== > - --- sys/kern/kern_environment.c (revision 273564) > +++ sys/kern/kern_environment.c (working copy) > @@ -262,7 +262,8 @@ void > freeenv(char *env) > { > > - - if (dynamic_kenv && env != NULL) { > + MPASS(env != NULL); > + if (dynamic_kenv) { > memset(env, 0, strlen(env)); > free(env, M_KENV); > } > There are at least 80 consumers of this function. Unless someone is up to reviewing them all, can we go with a warning + backtrace for the time being? -- Mateusz Guzik