All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <willy@w.ods.org>
To: Jesper Juhl <jesper.juhl@gmail.com>
Cc: laforge@netfilter.org, Stephen Frost <sfrost@snowman.net>,
	marcelo@kvack.org, netfilter-devel@lists.netfilter.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fix mem-leak in netfilter
Date: Sun, 7 May 2006 11:36:40 +0200	[thread overview]
Message-ID: <20060507093640.GF11191@w.ods.org> (raw)
In-Reply-To: <200605070426.10405.jesper.juhl@gmail.com>

On Sun, May 07, 2006 at 04:26:10AM +0200, Jesper Juhl wrote:
> The Coverity checker spotted that we may leak 'hold' in 
> net/ipv4/netfilter/ipt_recent.c::checkentry() when the following
> is true : 
>   if (!curr_table->status_proc) {
>     ...
>     if(!curr_table) {
>     ...
>       return 0;  <-- here we leak.
> Simply moving an existing vfree(hold); up a bit avoids the possible leak.
> 
> 
> (please keep me on CC when replying since I'm not subscribed 
>  to netfilter-devel)
> 
> 
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
> ---
> 
>  net/ipv4/netfilter/ipt_recent.c |    2 +-
>  1 files changed, 1 insertion(+), 1 deletion(-)
> 
> --- linux-2.6.17-rc3-git12-orig/net/ipv4/netfilter/ipt_recent.c	2006-05-07 03:25:38.000000000 +0200
> +++ linux-2.6.17-rc3-git12/net/ipv4/netfilter/ipt_recent.c	2006-05-07 04:16:26.000000000 +0200
> @@ -821,6 +821,7 @@ checkentry(const char *tablename,
>  	/* Create our proc 'status' entry. */
>  	curr_table->status_proc = create_proc_entry(curr_table->name, ip_list_perms, proc_net_ipt_recent);
>  	if (!curr_table->status_proc) {
> +		vfree(hold);
>  		printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for /proc entry.\n");
>  		/* Destroy the created table */
>  		spin_lock_bh(&recent_lock);
> @@ -845,7 +846,6 @@ checkentry(const char *tablename,
>  		spin_unlock_bh(&recent_lock);
>  		vfree(curr_table->time_info);
>  		vfree(curr_table->hash_table);
> -		vfree(hold);
>  		vfree(curr_table->table);
>  		vfree(curr_table);
>  		return 0;

Seems valid for 2.4.32 too. I'm queuing it up for Marcelo.

Regards,
Willy

WARNING: multiple messages have this Message-ID (diff)
From: Willy Tarreau <willy@w.ods.org>
To: Jesper Juhl <jesper.juhl@gmail.com>
Cc: linux-kernel@vger.kernel.org, Stephen Frost <sfrost@snowman.net>,
	laforge@netfilter.org, netfilter-devel@lists.netfilter.org,
	marcelo@kvack.org
Subject: Re: [PATCH] fix mem-leak in netfilter
Date: Sun, 7 May 2006 11:36:40 +0200	[thread overview]
Message-ID: <20060507093640.GF11191@w.ods.org> (raw)
In-Reply-To: <200605070426.10405.jesper.juhl@gmail.com>

On Sun, May 07, 2006 at 04:26:10AM +0200, Jesper Juhl wrote:
> The Coverity checker spotted that we may leak 'hold' in 
> net/ipv4/netfilter/ipt_recent.c::checkentry() when the following
> is true : 
>   if (!curr_table->status_proc) {
>     ...
>     if(!curr_table) {
>     ...
>       return 0;  <-- here we leak.
> Simply moving an existing vfree(hold); up a bit avoids the possible leak.
> 
> 
> (please keep me on CC when replying since I'm not subscribed 
>  to netfilter-devel)
> 
> 
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
> ---
> 
>  net/ipv4/netfilter/ipt_recent.c |    2 +-
>  1 files changed, 1 insertion(+), 1 deletion(-)
> 
> --- linux-2.6.17-rc3-git12-orig/net/ipv4/netfilter/ipt_recent.c	2006-05-07 03:25:38.000000000 +0200
> +++ linux-2.6.17-rc3-git12/net/ipv4/netfilter/ipt_recent.c	2006-05-07 04:16:26.000000000 +0200
> @@ -821,6 +821,7 @@ checkentry(const char *tablename,
>  	/* Create our proc 'status' entry. */
>  	curr_table->status_proc = create_proc_entry(curr_table->name, ip_list_perms, proc_net_ipt_recent);
>  	if (!curr_table->status_proc) {
> +		vfree(hold);
>  		printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for /proc entry.\n");
>  		/* Destroy the created table */
>  		spin_lock_bh(&recent_lock);
> @@ -845,7 +846,6 @@ checkentry(const char *tablename,
>  		spin_unlock_bh(&recent_lock);
>  		vfree(curr_table->time_info);
>  		vfree(curr_table->hash_table);
> -		vfree(hold);
>  		vfree(curr_table->table);
>  		vfree(curr_table);
>  		return 0;

Seems valid for 2.4.32 too. I'm queuing it up for Marcelo.

Regards,
Willy


  reply	other threads:[~2006-05-07  9:36 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-07  2:26 [PATCH] fix mem-leak in netfilter Jesper Juhl
2006-05-07  9:36 ` Willy Tarreau [this message]
2006-05-07  9:36   ` Willy Tarreau
2006-05-07 22:42   ` Grant Coady
2006-05-08  5:07     ` Willy Tarreau
2006-05-08  5:43       ` David S. Miller
2006-05-08  5:43         ` David S. Miller
2006-05-08  8:36         ` Amin Azez
2006-05-08  8:36           ` Amin Azez
2006-05-08  9:08           ` Juergen Kreileder
2006-05-08  9:08             ` Juergen Kreileder
2006-05-12  7:40         ` Patrick McHardy
2006-05-12  7:40           ` Patrick McHardy
2006-05-12 11:09           ` Jesper Juhl
2006-05-12 11:33             ` Patrick McHardy
2006-05-12 12:13               ` Jesper Juhl
2006-05-12 12:40                 ` Willy Tarreau
2006-05-12 12:40                   ` Willy Tarreau
2006-05-12 12:49                   ` Patrick McHardy
2006-05-12 12:49                     ` Patrick McHardy
2006-05-12 13:42               ` Amin Azez
2006-05-15  8:25                 ` Patrick McHardy
2006-05-15  8:25                   ` Patrick McHardy
2006-05-15 14:28                   ` Stephen Frost
2006-05-15 14:28                     ` Stephen Frost
2006-05-15 18:49                     ` Patrick McHardy
2006-05-15 18:49                       ` Patrick McHardy
2006-05-15 19:27                       ` Stephen Frost
2006-05-15 19:27                         ` Stephen Frost
2006-05-15 20:09                         ` Patrick McHardy
2006-05-15 20:09                           ` Patrick McHardy
2006-05-15 20:41                           ` Stephen Frost
2006-05-15 20:41                             ` Stephen Frost
2006-05-15 20:45                             ` Patrick McHardy
2006-05-15 20:45                               ` Patrick McHardy
2006-05-15 21:03                             ` Stephen Frost
2006-05-17  6:26                               ` Patrick McHardy
2006-05-17  6:59                                 ` David S. Miller
2006-05-17  6:59                                   ` David S. Miller
2006-05-17  7:19                                   ` Patrick McHardy
2006-05-17  7:19                                     ` Patrick McHardy
2006-05-17 10:55                                     ` Stephen Frost
2006-05-17  7:09                                 ` David S. Miller
2006-05-17  7:13                                   ` Roland Dreier
2006-05-17  7:19                                   ` Patrick McHardy
2006-05-17 13:14                                 ` Stephen Frost
2006-05-17 13:14                                   ` Stephen Frost
2006-06-01 13:43                                 ` Andrew James Wade
2006-06-01 14:53                                   ` Patrick McHardy
2006-06-02 21:32                                     ` Andrew James Wade

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=20060507093640.GF11191@w.ods.org \
    --to=willy@w.ods.org \
    --cc=jesper.juhl@gmail.com \
    --cc=laforge@netfilter.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@kvack.org \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=sfrost@snowman.net \
    /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.