Patchwork [6/6] netfilter: nf_conntrack: fix early_drop with reliable event delivery

login
register
mail settings
Submitter Pablo Neira
Date March 6, 2012, 11:22 a.m.
Message ID <1331032975-5303-7-git-send-email-pablo@netfilter.org>
Download mbox | patch
Permalink /patch/144921/
State Awaiting Upstream
Headers show

Comments

Pablo Neira - March 6, 2012, 11:22 a.m.
From: Pablo Neira Ayuso <pablo@netfilter.org>

If reliable event delivery is enabled and ctnetlink fails to deliver
the destroy event in early_drop, the conntrack subsystem cannot
drop any the candidate flow that was planned to be evicted.

Reported-by: Kerin Millar <kerframil@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_conntrack_core.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
David Miller - March 6, 2012, 8:16 p.m.
From: pablo@netfilter.org
Date: Tue,  6 Mar 2012 12:22:55 +0100

> From: Pablo Neira Ayuso <pablo@netfilter.org>
> 
> If reliable event delivery is enabled and ctnetlink fails to deliver
> the destroy event in early_drop, the conntrack subsystem cannot
> drop any the candidate flow that was planned to be evicted.
> 
> Reported-by: Kerin Millar <kerframil@gmail.com>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

Applied.

> +		/* Check if we indeed killed this entry. Reliable event
> +		   delivery may have inserted it into the dying list. */
> +		if (test_bit(IPS_DYING_BIT, &ct->status)) {

Please don't allow misformatted comments like this into your
tree next time, this should be:

		/* Check if we indeed killed this entry. Reliable event
		 * delivery may have inserted it into the dying list.
		 */
--
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
Pablo Neira - March 7, 2012, 1:19 p.m.
On Tue, Mar 06, 2012 at 03:16:18PM -0500, David Miller wrote:
> From: pablo@netfilter.org
> Date: Tue,  6 Mar 2012 12:22:55 +0100
> 
> > From: Pablo Neira Ayuso <pablo@netfilter.org>
> > 
> > If reliable event delivery is enabled and ctnetlink fails to deliver
> > the destroy event in early_drop, the conntrack subsystem cannot
> > drop any the candidate flow that was planned to be evicted.
> > 
> > Reported-by: Kerin Millar <kerframil@gmail.com>
> > Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> 
> Applied.
> 
> > +		/* Check if we indeed killed this entry. Reliable event
> > +		   delivery may have inserted it into the dying list. */
> > +		if (test_bit(IPS_DYING_BIT, &ct->status)) {
> 
> Please don't allow misformatted comments like this into your
> tree next time, this should be:
> 
> 		/* Check if we indeed killed this entry. Reliable event
> 		 * delivery may have inserted it into the dying list.
> 		 */

Thanks for spotting this.

Will in the future (probably some patches that I took for net-next
may not follow this format either, but for upcoming patches I will).
--
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

Patch

diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index ed86a3b..fa4b82c 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -635,8 +635,12 @@  static noinline int early_drop(struct net *net, unsigned int hash)
 
 	if (del_timer(&ct->timeout)) {
 		death_by_timeout((unsigned long)ct);
-		dropped = 1;
-		NF_CT_STAT_INC_ATOMIC(net, early_drop);
+		/* Check if we indeed killed this entry. Reliable event
+		   delivery may have inserted it into the dying list. */
+		if (test_bit(IPS_DYING_BIT, &ct->status)) {
+			dropped = 1;
+			NF_CT_STAT_INC_ATOMIC(net, early_drop);
+		}
 	}
 	nf_ct_put(ct);
 	return dropped;