netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Holger Eitzenberger <holger@eitzenberger.org>
Cc: netfilter-devel@vger.kernel.org,
	Holger Eitzenberger <holger.eitzenberger@sophos.com>
Subject: Re: [FIX 1/1] sip: add missing RCU reader lock
Date: Fri, 20 Sep 2013 17:55:40 +0100	[thread overview]
Message-ID: <20130920165539.GA27970@macbook.localnet> (raw)
In-Reply-To: <20130920155817.660882995@eitzenberger.org>

On Fri, Sep 20, 2013 at 05:52:18PM +0200, Holger Eitzenberger wrote:
> Currently set_expected_rtp_rtcp() in the SIP helper uses
> rcu_dereference() two times to access two different NAT hook
> functions.  However, only the first one is protected properly by
> the RCU reader lock, but the 2nd isn't.

Its more a cosmetic thing since we rely on all netfilter hooks being
rcu_read_lock()ed by nf_hook_slow() in many places anyways.

> I chose to not just extend the first RCU protected area but putting
> the rcu_read_unlock() down, because there is a 'return' in between.

I'd suggest to do that since your patch still doesn't cover the
direct_rtp nf_nat_sdp_port_hook dereference. Actually with your patch
we have unbalanced RCU locking since the direct_rtp case contains
a "goto err1".

> 
> Signed-off-by: Holger Eitzenberger <holger.eitzenberger@sophos.com>
> 
> Index: net-next/net/netfilter/nf_conntrack_sip.c
> ===================================================================
> --- net-next.orig/net/netfilter/nf_conntrack_sip.c
> +++ net-next/net/netfilter/nf_conntrack_sip.c
> @@ -983,6 +983,7 @@ static int set_expected_rtp_rtcp(struct
>  	if (skip_expect)
>  		return NF_ACCEPT;
>  
> +	rcu_read_lock();
>  	rtp_exp = nf_ct_expect_alloc(ct);
>  	if (rtp_exp == NULL)
>  		goto err1;
> @@ -1012,6 +1013,7 @@ static int set_expected_rtp_rtcp(struct
>  err2:
>  	nf_ct_expect_put(rtp_exp);
>  err1:
> +	rcu_read_unlock();
>  	return ret;
>  }
>  

  reply	other threads:[~2013-09-20 18:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-20 15:52 [FIX 0/1] sip: add missing RCU reader lock in set_expected_rtp_rtcp() Holger Eitzenberger
2013-09-20 15:52 ` [FIX 1/1] sip: add missing RCU reader lock Holger Eitzenberger
2013-09-20 16:55   ` Patrick McHardy [this message]
2013-09-20 20:20     ` Holger Eitzenberger

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=20130920165539.GA27970@macbook.localnet \
    --to=kaber@trash.net \
    --cc=holger.eitzenberger@sophos.com \
    --cc=holger@eitzenberger.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;
as well as URLs for NNTP newsgroup(s).