Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Mar 2015 11:15:45 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Ian Lepore <ian@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r279997 - head/sys/netinet
Message-ID:  <3051755.qWx5SR0ixE@ralph.baldwin.cx>
In-Reply-To: <1426377491.39727.4.camel@freebsd.org>
References:  <201503141811.t2EIBPeE006504@svn.freebsd.org> <12123739.Rz3jP8R4fM@ralph.baldwin.cx> <1426377491.39727.4.camel@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday, March 14, 2015 05:58:11 PM Ian Lepore wrote:
> On Sat, 2015-03-14 at 17:52 -0400, John Baldwin wrote:
> > 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.
> > 
> 
> Doh!  I was trying to keep an eye out for locks, but I missed that one.
> Fixed in r280014.
> 
> I'm at that point in a big maintenance task where I've looked at too
> much code in too short a time, thanks for keeping a watchful eye on all
> this.

No problem.  I've replied to a few others that I think need a similar fix.
However, fixing the larger bug is much appreciated. :)

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3051755.qWx5SR0ixE>