From owner-svn-src-all@FreeBSD.ORG Sat Mar 14 21:52:22 2015 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 7B16A434; Sat, 14 Mar 2015 21:52:22 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 53DF875A; Sat, 14 Mar 2015 21:52:22 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-54-116-245.nwrknj.fios.verizon.net [173.54.116.245]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 6C171B93C; Sat, 14 Mar 2015 17:52:20 -0400 (EDT) From: John Baldwin To: Ian Lepore Subject: Re: svn commit: r279997 - head/sys/netinet Date: Sat, 14 Mar 2015 17:52:12 -0400 Message-ID: <12123739.Rz3jP8R4fM@ralph.baldwin.cx> User-Agent: KMail/4.14.2 (FreeBSD/10.1-STABLE; KDE/4.14.2; amd64; ; ) In-Reply-To: <201503141811.t2EIBPeE006504@svn.freebsd.org> References: <201503141811.t2EIBPeE006504@svn.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Sat, 14 Mar 2015 17:52:20 -0400 (EDT) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org 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: Sat, 14 Mar 2015 21:52:22 -0000 On Saturday, March 14, 2015 06:11:25 PM Ian Lepore wrote: > Author: ian > Date: Sat Mar 14 18:11:24 2015 > New Revision: 279997 > URL: https://svnweb.freebsd.org/changeset/base/279997 > > Log: > Use sbuf_new_for_sysctl() instead of plain sbuf_new() to ensure sysctl > string returned to userland is nulterminated. > > PR: 195668 This is not safe. sbuf_printf() is invoked with a lock held, so it isn't safe for the sbuf code to do a drain here. With sbuf_new_for_sysctl(), any call to an sbuf routine is a potential page fault, so the handler must either use sysctl_wire_old_buffer(), or the contents need to be output in one go. For this case I would prefer to use sbuf_len(sb) + 1 (or add INCLUDENUL to the args when creating it) and leave the sole SYSCTL_OUT() at the end. You will want to check the one or two other places you converted for this same issue as well. -- John Baldwin