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] [day] [month] [year] [list]
Message-ID: <20150109230109.GA4549@zenon.in.qult.net>
Date:	Sat, 10 Jan 2015 00:01:09 +0100
From:	Ignacy Gawędzki 
	<ignacy.gawedzki@...en-communications.fr>
To:	Cong Wang <cwang@...pensource.com>
Cc:	netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH net v3] gen_stats.c: Duplicate xstats buffer for later use

On Fri, Jan 09, 2015 at 02:35:41PM -0800, thus spake Cong Wang:
> On Thu, Jan 8, 2015 at 5:30 AM, Ignacy Gawędzki
> > diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
> > index 0c08062..c9f1fa8 100644
> > --- a/net/core/gen_stats.c
> > +++ b/net/core/gen_stats.c
> > @@ -32,6 +32,9 @@ gnet_stats_copy(struct gnet_dump *d, int type, void *buf, int size)
> >         return 0;
> >
> >  nla_put_failure:
> > +       kfree(d->xstats);
> > +       d->xstats = NULL;
> > +       d->xstats_len = 0;
> >         spin_unlock_bh(d->lock);
> >         return -1;
> >  }
> 
> Although it is not your fault, the API sucks, gnet_stats_copy()
> should not need to care about the error path of its caller.
> I will cook a patch for it.

That would be great, as I'm certainly not that fluent in kernel code.

> > @@ -305,7 +308,10 @@ int
> >  gnet_stats_copy_app(struct gnet_dump *d, void *st, int len)
> >  {
> >         if (d->compat_xstats) {
> > -               d->xstats = st;
> > +               kfree(d->xstats);
> > +               d->xstats = kmemdup(st, len, GFP_ATOMIC);
> > +               if (!d->xstats)
> > +                       goto kmalloc_failure;
> 
> Do we really need to call kfree() before kmemdup()?
> I don't think gnet_stats_copy_app() is supposed to be called
> twice before gnet_stats_copy_finish()?

It's not, but I figured it's safer that way and probably not that expensive
given the frequency with which calls to these functions are performed in
practice.

-- 
Ignacy Gawędzki
R&D Engineer
Green Communications
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ