From owner-svn-src-all@FreeBSD.ORG Fri Jun 27 20:19:14 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1A83CF19; Fri, 27 Jun 2014 20:19:14 +0000 (UTC) Received: from mail-we0-x22f.google.com (mail-we0-x22f.google.com [IPv6:2a00:1450:400c:c03::22f]) (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 1170D2864; Fri, 27 Jun 2014 20:19:12 +0000 (UTC) Received: by mail-we0-f175.google.com with SMTP id k48so5707350wev.34 for ; Fri, 27 Jun 2014 13:19:10 -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:in-reply-to:user-agent; bh=w0l2a3MYhWdVB6iXzEquJTuVAfcUsCK8Dd6PFAA+TLA=; b=Dst+BoMg0v79NDlG3vJqn4jmDyAsTNCaVitUtUUxj6t+RG5OHZBPP8kItos/dwKvlR q0B1s5/7sxU5a+fxaifkoL76opf6py9vrFhye+eCgSnTICU9LmAFYyXuAnB5PWNwYBkJ 2w8yMXgoliQ3drURgZFBLBLOCGKkvKDxMPRMaGtyp6XR2CawAb0WpKSw90kCt+3MQ5Oy NzHXUNOrq4T1XuB7R6+nbsqwDGzeNofLtSgsVct1w2Z19n0PjtHr6KaBlVhftBF+1jiv c1TAQt43ZZijqcGM68BKRnJ4LcBkPQ+Tn9EF6NigwIdoEnL5SVglGJNw6Lnnj4S7QxF6 Yz/Q== X-Received: by 10.180.37.230 with SMTP id b6mr14048562wik.47.1403900350783; Fri, 27 Jun 2014 13:19:10 -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 gh16sm204437wic.3.2014.06.27.13.19.09 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 27 Jun 2014 13:19:10 -0700 (PDT) Date: Fri, 27 Jun 2014 22:19:07 +0200 From: Mateusz Guzik To: Ed Maste Subject: Re: svn commit: r267961 - in head/sys: amd64/acpica amd64/amd64 amd64/pci amd64/vmm arm/arm arm/freescale/imx arm/xscale/ixp425 cam cam/ata cam/ctl cam/scsi cddl/compat/opensolaris/kern cddl/contrib/op... Message-ID: <20140627201907.GC22501@dft-labs.eu> References: <201406271633.s5RGXih6076565@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , Hans Petter Selasky X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 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: Fri, 27 Jun 2014 20:19:14 -0000 On Fri, Jun 27, 2014 at 03:27:30PM -0400, Ed Maste wrote: > On 27 June 2014 12:33, Hans Petter Selasky wrote: > > Author: hselasky > > Date: Fri Jun 27 16:33:43 2014 > > New Revision: 267961 > > URL: http://svnweb.freebsd.org/changeset/base/267961 > > At r267969 sysctl strings are broken for me: > > # uname -a > uname: sysctl: Cannot allocate memory > # sysctl kern.ostype > # > The problem was with (arg2 == 0) check. I have a hack which restores things for me, but since the check was put in place just removing it may not be the correct approach. That said, I would suggest reverting the change for the time being until it is concluded what is the correct thing to do here. fwiw, the hack is: diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index cb5a266..9b7f108 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1210,21 +1210,23 @@ sysctl_handle_string(SYSCTL_HANDLER_ARGS) size_t outlen; int error = 0; - /* check for zero-length buffer */ - if (arg2 == 0) - return (ENOMEM); - if (req->oldptr != NULL) { char *tmparg; - /* try to make a coherent snapshot of the string */ - tmparg = malloc(arg2, M_SYSCTLTMP, M_WAITOK); - memcpy(tmparg, arg1, arg2); + if (arg2 != 0) { + /* try to make a coherent snapshot of the string */ + tmparg = malloc(arg2, M_SYSCTLTMP, M_WAITOK); + memcpy(tmparg, arg1, arg2); + outlen = strnlen(tmparg, arg2 - 1) + 1; + } else { + tmparg = arg1; + outlen = strlen((char *)arg1)+1; + } - outlen = strnlen(tmparg, arg2 - 1) + 1; error = SYSCTL_OUT(req, tmparg, outlen); - free(tmparg, M_SYSCTLTMP); + if (tmparg != arg1) + free(tmparg, M_SYSCTLTMP); } else { outlen = strnlen((char *)arg1, arg2 - 1) + 1; error = SYSCTL_OUT(req, NULL, outlen); -- Mateusz Guzik