All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Michal Kubecek <mkubecek@suse.cz>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
	Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>,
	Florian Westphal <fw@strlen.de>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH] netfilter: properly initialize xt_table_info structure
Date: Thu, 17 May 2018 11:29:09 +0200	[thread overview]
Message-ID: <20180517092909.GA17597@kroah.com> (raw)
In-Reply-To: <20180517085951.2wxvcg5herkjaxda@unicorn.suse.cz>

On Thu, May 17, 2018 at 10:59:51AM +0200, Michal Kubecek wrote:
> On Thu, May 17, 2018 at 10:44:42AM +0200, Greg Kroah-Hartman wrote:
> > When allocating a xt_table_info structure, we should be clearing out the
> > full amount of memory that was allocated, not just the "header" of the
> > structure.  Otherwise odd values could be passed to userspace, which is
> > not a good thing.
> > 
> > Cc: stable <stable@vger.kernel.org>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >  net/netfilter/x_tables.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
> > index cb7cb300c3bc..a300e8252bb6 100644
> > --- a/net/netfilter/x_tables.c
> > +++ b/net/netfilter/x_tables.c
> > @@ -1187,7 +1187,7 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size)
> >  	if (!info)
> >  		return NULL;
> >  
> > -	memset(info, 0, sizeof(*info));
> > +	memset(info, 0, sz);
> >  	info->size = size;
> >  	return info;
> >  }
> > -- 
> > 2.17.0
> > 
> 
> Or we can replace kvmalloc() by kvzalloc() and remove the memset().

That works for me too, either is sufficient to solve the problem.

Let me go respin this, less lines of code is always better :)

thanks,

greg k-h

  reply	other threads:[~2018-05-17  9:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-17  8:44 [PATCH] netfilter: properly initialize xt_table_info structure Greg Kroah-Hartman
2018-05-17  8:59 ` Michal Kubecek
2018-05-17  9:29   ` Greg Kroah-Hartman [this message]
2018-05-17  9:34   ` [PATCH v2] " Greg Kroah-Hartman
2018-05-17  9:55     ` Eric Dumazet
2018-05-17 10:09       ` Greg Kroah-Hartman
2018-05-17 10:42         ` Jan Engelhardt
2018-05-17 13:20           ` Greg Kroah-Hartman
2018-05-18  9:27             ` Florian Westphal
2018-05-18 11:04               ` Greg Kroah-Hartman
2018-05-26 14:54               ` Greg Kroah-Hartman
     [not found]                 ` <CANZU63WyNL4qUJx2eS3gokPMBJLn5=C4-bnOSEF5trX3jGngUA@mail.gmail.com>
2018-05-31  8:24                   ` Florian Westphal
2018-05-31  8:51                     ` Greg Kroah-Hartman
2018-05-31  9:07                       ` Florian Westphal
2018-05-31 10:11                         ` Greg Kroah-Hartman
     [not found]                       ` <CANZU63VE7fWNL+PJrLp7-5PBS6R6RQPvhw2QgqAK8NhX4uQc9Q@mail.gmail.com>
2018-05-31 11:23                         ` Greg Kroah-Hartman
2018-05-31 11:32                         ` Michal Kubecek
2018-05-31 11:55                           ` Michal Kubecek
2018-05-31 16:25                             ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180517092909.GA17597@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=coreteam@netfilter.org \
    --cc=fw@strlen.de \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.