lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 1 Aug 2018 17:03:44 +0200
From:   Greg Kurz <groug@...d.org>
To:     Dominique Martinet <asmadeus@...ewreck.org>
Cc:     v9fs-developer@...ts.sourceforge.net,
        linux-fsdevel@...r.kernel.org,
        Matthew Wilcox <willy@...radead.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [V9fs-developer] [PATCH 1/2] net/9p: embed fcall in req to
 round down buffer allocs

On Wed, 1 Aug 2018 16:38:40 +0200
Dominique Martinet <asmadeus@...ewreck.org> wrote:

> Greg Kurz wrote on Wed, Aug 01, 2018:
> > > @@ -263,13 +261,13 @@ p9_tag_alloc(struct p9_client *c, int8_t type, unsigned int max_size)
> > >  	if (!req)
> > >  		return NULL;
> > >  
> > > +	if (p9_fcall_alloc(&req->tc, alloc_msize))
> > > +		goto free;
> > > +	if (p9_fcall_alloc(&req->rc, alloc_msize))
> > >  		goto free;  
> > 
> > Hmm... if the first allocation fails, we will kfree() req->rc.sdata.
> > 
> > Are we sure we won't have a stale pointer or uninitialized data in
> > there ?  
> 
> Yeah, Jun pointed that out and I have a v2 that only frees as needed
> with an extra goto (I sent an incremental diff in my reply to his
> comment here[1])
> 
> [1] https://lkml.kernel.org/r/20180731011256.GA30388@nautica
> 
> > And even if we don't with the current code base, this is fragile and
> > could be easily broken.
> > 
> > I think you should drop this hunk and rather rename p9_fcall_alloc() to
> > p9_fcall_alloc_sdata() instead, since this is what the function is
> > actually doing with this patch applied.  
> 
> Hmm. I agree the naming isn't accurate, but even if we rename it we'll
> need to pass a pointer to fcall as argument as it inits its capacity.
> p9_fcall_init(fc, msize) might be simpler?
> 

Ah yes you're right... alloc is a bit misleading then. I agree that
p9_fcall_init() is more appropriate in this case.

And maybe you should introduce p9_fcall_fini() or _release() for
completeness. It would only do kfree() for a start, but it would
then evolve to be like the p9_fcall_kfree() function from patch 2.

> (I'm not sure I follow what you mean by 'drop this hunk', to be honest,
> did you want a single function call to init both maybe?)
> 

I was meaning "keep the same logic in p9_tag_alloc()", something like:

	req->tc.sdata = p9_fcall_alloc_sdata(&req->tc, alloc_msize);
	req->rc.sdata = p9_fcall_alloc_sdata(&req->tc, alloc_msize);
	if (!req->tc.sdata || !req->rc.sdata)

But I agree the way you did is cleaner.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ