netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Loganaden Velvindron <logan@elandsys.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 1/1 net-next] net: bridge: netfilter: use vzalloc() instead of vmalloc() for counterstmp
Date: Sun, 8 Nov 2015 21:41:15 +0100	[thread overview]
Message-ID: <20151108204115.GA2629@salvia> (raw)
In-Reply-To: <20151030123303.GA19481@mx.elandsys.com>

On Fri, Oct 30, 2015 at 05:33:03AM -0700, Loganaden Velvindron wrote:
> counterstmp is not cleared before it is used in get_counters(). it might be 
> leaked partially when it is sent to userland later on.

get_counters() is memcpy'ing the old counter to the counterstmp area
and updating it.

Where is there leak?

> Signed-off-by: Loganaden Velvindron <logan@elandsys.com>
> ---
>  net/bridge/netfilter/ebtables.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
> index f46ca41..26922e9 100644
> --- a/net/bridge/netfilter/ebtables.c
> +++ b/net/bridge/netfilter/ebtables.c
> @@ -989,7 +989,7 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
>  	   the check on the size is done later, when we have the lock */
>  	if (repl->num_counters) {
>  		unsigned long size = repl->num_counters * sizeof(*counterstmp);
> -		counterstmp = vmalloc(size);
> +		counterstmp = vzalloc(size);
>  		if (!counterstmp)
>  			return -ENOMEM;
>  	}
> @@ -1410,7 +1410,7 @@ static int copy_counters_to_user(struct ebt_table *t,
>  		return -EINVAL;
>  	}
>  
> -	counterstmp = vmalloc(nentries * sizeof(*counterstmp));
> +	counterstmp = vzalloc(nentries * sizeof(*counterstmp));
>  	if (!counterstmp)
>  		return -ENOMEM;
>  
> -- 
> 2.6.1
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2015-11-08 20:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30 12:33 [PATCH 1/1 net-next] net: bridge: netfilter: use vzalloc() instead of vmalloc() for counterstmp Loganaden Velvindron
2015-11-08 20:41 ` Pablo Neira Ayuso [this message]
2015-11-08 20:52   ` Loganaden Velvindron
2015-11-08 21:30     ` Pablo Neira Ayuso
2015-11-08 21:26       ` Loganaden Velvindron

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=20151108204115.GA2629@salvia \
    --to=pablo@netfilter.org \
    --cc=logan@elandsys.com \
    --cc=netfilter-devel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).