Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: kaber@trash.net
Cc: davem@davemloft.net, netfilter-devel@vger.kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH 4/6] netfilter: fix a race in nf_ct_ext_create()
Date: Wed, 22 Sep 2010 09:23:40 +0200	[thread overview]
Message-ID: <1285140220.6378.211.camel@edumazet-laptop> (raw)
In-Reply-To: <1285139854-11827-5-git-send-email-kaber@trash.net>

Le mercredi 22 septembre 2010 à 09:17 +0200, kaber@trash.net a écrit :
> From: Eric Dumazet <Eric Dumazet>
> 

strange email address ;)

> As soon as rcu_read_unlock() is called, there is no guarantee current
> thread can safely derefence t pointer, rcu protected.
> 
> Fix is to copy t->alloc_size in a temporary variable.
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Signed-off-by: Patrick McHardy <kaber@trash.net>
> ---
>  net/netfilter/nf_conntrack_extend.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c
> index 7dcf7a4..8d9e4c9 100644
> --- a/net/netfilter/nf_conntrack_extend.c
> +++ b/net/netfilter/nf_conntrack_extend.c
> @@ -48,15 +48,17 @@ nf_ct_ext_create(struct nf_ct_ext **ext, enum nf_ct_ext_id id, gfp_t gfp)
>  {
>  	unsigned int off, len;
>  	struct nf_ct_ext_type *t;
> +	size_t alloc_size;
>  
>  	rcu_read_lock();
>  	t = rcu_dereference(nf_ct_ext_types[id]);
>  	BUG_ON(t == NULL);
>  	off = ALIGN(sizeof(struct nf_ct_ext), t->align);
>  	len = off + t->len;
> +	alloc_size = t->alloc_size;
>  	rcu_read_unlock();
>  
> -	*ext = kzalloc(t->alloc_size, gfp);
> +	*ext = kzalloc(alloc_size, gfp);
>  	if (!*ext)
>  		return NULL;
>  


--
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:[~2010-09-22  7:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-22  7:17 [PATCH 0/6] netfilter: netfilter fixes kaber
2010-09-22  7:17 ` [PATCH 1/6] netfilter: tproxy: nf_tproxy_assign_sock() can handle tw sockets kaber
2010-09-22  7:17 ` [PATCH 2/6] netfilter: nf_ct_sip: default to NF_ACCEPT in sip_help_tcp() kaber
2010-09-22  7:17 ` [PATCH 3/6] netfilter: fix ipt_REJECT TCP RST routing for indev == outdev kaber
2010-09-22  7:17 ` [PATCH 4/6] netfilter: fix a race in nf_ct_ext_create() kaber
2010-09-22  7:23   ` Eric Dumazet [this message]
2010-09-22  7:28     ` Patrick McHardy
2010-09-22  7:17 ` [PATCH 5/6] netfilter: nf_nat_snmp: fix checksum calculation (v4) kaber
2010-09-22  7:17 ` [PATCH 6/6] netfilter: nf_conntrack_defrag: check socket type before touching nodefrag flag kaber
2010-09-22 20:12 ` [PATCH 0/6] netfilter: netfilter fixes David Miller
2010-09-23  3:49   ` 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=1285140220.6378.211.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --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