All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Dmitry Mishin <dim@openvz.org>
Cc: Kirill Korotaev <dev@openvz.org>,
	netfilter-devel@lists.netfilter.org,
	Vasily Averin <vvs@openvz.org>,
	devel@openvz.org
Subject: Re: [PATCH] iptables compat code error way & module refcounting fix
Date: Mon, 30 Oct 2006 16:45:19 +0100	[thread overview]
Message-ID: <45461E0F.6010504@trash.net> (raw)
In-Reply-To: <200610301331.32650.dim@openvz.org>

Dmitry Mishin wrote:
> This patch fixes bug in iptables modules refcounting on compat error way.
> 
> As we are getting modules in check_compat_entry_size_and_hooks(), in case of
> later error, we should put them all in translate_compat_table(), not  in the
> compat_copy_entry_from_user() or compat_copy_match_from_user(), as it is now.
> 
> Signed-off-by: Dmitry Mishin <dim@openvz.org>
> Acked-by: Vasily Averin <vvs@openvz.org>
> Acked-by: Kirill Korotaev <dev@openvz.org>
> 
>  ip_tables.c |   36 +++++++++++-------------------------
>  1 file changed, 11 insertions(+), 25 deletions(-)
> 
> ----
> @@ -1618,7 +1603,7 @@ translate_compat_table(const char *name,
>  		unsigned int *hook_entries,
>  		unsigned int *underflows)
>  {
> -	unsigned int i;
> +	unsigned int i, j;
>  	struct xt_table_info *newinfo, *info;
>  	void *pos, *entry0, *entry1;
>  	unsigned int size;
> @@ -1636,21 +1621,21 @@ translate_compat_table(const char *name,
>  	}
>  
>  	duprintf("translate_compat_table: size %u\n", info->size);
> -	i = 0;
> +	j = 0;
>  	xt_compat_lock(AF_INET);
>  	/* Walk through entries, checking offsets. */
>  	ret = IPT_ENTRY_ITERATE(entry0, total_size,
>  				check_compat_entry_size_and_hooks,
>  				info, &size, entry0,
>  				entry0 + total_size,
> -				hook_entries, underflows, &i, name);
> +				hook_entries, underflows, &j, name);
>  	if (ret != 0)
>  		goto out_unlock;
>  
>  	ret = -EINVAL;
> -	if (i != number) {
> +	if (j != number) {
>  		duprintf("translate_compat_table: %u not %u entries\n",
> -			 i, number);
> +			 j, number);
>  		goto out_unlock;
>  	}
>  
> @@ -1709,6 +1694,7 @@ translate_compat_table(const char *name,
>  free_newinfo:
>  	xt_free_table_info(newinfo);
>  out:
> +	IPT_ENTRY_ITERATE(entry0, total_size, cleanup_entry, &j);
>  	return ret;
>  out_unlock:
>  	xt_compat_unlock(AF_INET);
> 

This doesn't look right, if we fail at xt_alloc_table_info for
example the module references are not released. What case
exactly is this patch supposed to fix?

  reply	other threads:[~2006-10-30 15:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-30 10:31 [PATCH] iptables compat code error way & module refcounting fix Dmitry Mishin
2006-10-30 15:45 ` Patrick McHardy [this message]
2006-10-30 15:57   ` Dmitry Mishin
2006-10-30 16:04     ` Patrick McHardy

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=45461E0F.6010504@trash.net \
    --to=kaber@trash.net \
    --cc=dev@openvz.org \
    --cc=devel@openvz.org \
    --cc=dim@openvz.org \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=vvs@openvz.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.