From f2c06f0484a15d0779ab998953e8e2cc82e976c9 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Fri, 25 Jul 2003 01:18:17 -0700 Subject: [PATCH] [NETFILTER]: Fix locking of ipt_helper. --- net/ipv4/netfilter/ipt_helper.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/net/ipv4/netfilter/ipt_helper.c b/net/ipv4/netfilter/ipt_helper.c index 1f7efb91c5e8c..28ab46445e4a9 100644 --- a/net/ipv4/netfilter/ipt_helper.c +++ b/net/ipv4/netfilter/ipt_helper.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,7 @@ match(const struct sk_buff *skb, struct ip_conntrack_expect *exp; struct ip_conntrack *ct; enum ip_conntrack_info ctinfo; + int ret = 0; ct = ip_conntrack_get((struct sk_buff *)skb, &ctinfo); if (!ct) { @@ -47,23 +49,27 @@ match(const struct sk_buff *skb, } exp = ct->master; + READ_LOCK(&ip_conntrack_lock); if (!exp->expectant) { DEBUGP("ipt_helper: expectation %p without expectant !?!\n", exp); - return 0; + goto out_unlock; } if (!exp->expectant->helper) { DEBUGP("ipt_helper: master ct %p has no helper\n", exp->expectant); - return 0; + goto out_unlock; } DEBUGP("master's name = %s , info->name = %s\n", exp->expectant->helper->name, info->name); - return !strncmp(exp->expectant->helper->name, info->name, - strlen(exp->expectant->helper->name)) ^ info->invert; + ret = !strncmp(exp->expectant->helper->name, info->name, + strlen(exp->expectant->helper->name)) ^ info->invert; +out_unlock: + READ_UNLOCK(&ip_conntrack_lock); + return ret; } static int check(const char *tablename, -- 2.53.0