Skip to contentSkip to conversation

netfilter: xt_CT: checking for IS_ERR() instead of NULL

PATCH Applied Dan Carpenter 3 participants 8 messages Jul 27, 2015 – Aug 3, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: xt_CT: checking for IS_ERR() instead of NULL

We recently changed this from nf_conntrack_alloc() to nf_ct_tmpl_alloc() so the error handling needs to changed to check for NULL instead of IS_ERR().

Fixes 0838aa7fcfcd ('netfilter: fix netns dependencies with conntrack templates')
net/netfilter/xt_CT.c +3 -2
index c663003..43ddeee 100644
@@ -202,9 +202,10 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par,
 		goto err1;
 
 	ct = nf_ct_tmpl_alloc(par->net, info->zone, GFP_KERNEL);
-	ret = PTR_ERR(ct);
-	if (IS_ERR(ct))
+	if (!ct) {
+		ret = -ENOMEM;
 		goto err2;
+	}
 
 	ret = 0;
 	if ((info->ct_events || info->exp_events) &&
maintainer Applied
#1 lore raw
Quoted 6 lines · Dan Carpenter

We recently changed this from nf_conntrack_alloc() to nf_ct_tmpl_alloc() so the error handling needs to changed to check for NULL instead of IS_ERR().

Fixes 0838aa7fcfcd ('netfilter: fix netns dependencies with conntrack templates')

Applied, thanks.

I have also appended this chunk, since synproxy is also affected:

net/netfilter/nf_synproxy_core.c +1 -1
@@ -353,7 +353,7 @@ static int __net_init synproxy_net_init(struct net *net)
        int err = -ENOMEM;
 
        ct = nf_ct_tmpl_alloc(net, 0, GFP_KERNEL);
-       if (IS_ERR(ct)) {
+       if (!ct) {
                err = PTR_ERR(ct);
                goto err1;
        }
Quoted 17 lines
net/netfilter/xt_CT.c +3 -2
index c663003..43ddeee 100644
@@ -202,9 +202,10 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par,
 		goto err1;
 
 	ct = nf_ct_tmpl_alloc(par->net, info->zone, GFP_KERNEL);
-	ret = PTR_ERR(ct);
-	if (IS_ERR(ct))
+	if (!ct) {
+		ret = -ENOMEM;
 		goto err2;
+	}
 
 	ret = 0;
 	if ((info->ct_events || info->exp_events) &&
#2 lore raw
Quoted 1 line · Pablo Neira Ayuso

I have also appended this chunk, since synproxy is also affected:

Thanks. I have rechecked my scripts and I *should* have caught that. I'm not sure what went wrong...

regards,
dan carpenter

#3 lore raw
Quoted 5 lines · Dan Carpenter
Quoted 1 line · Pablo Neira Ayuso

I have also appended this chunk, since synproxy is also affected:

Thanks. I have rechecked my scripts and I *should* have caught that. I'm not sure what went wrong...

Never trust robots :-P

#4 lore raw
In reply to Pablo Neira Ayuso
Quoted 15 lines · Pablo Neira Ayuso
Quoted 6 lines · Dan Carpenter

We recently changed this from nf_conntrack_alloc() to nf_ct_tmpl_alloc() so the error handling needs to changed to check for NULL instead of IS_ERR().

Fixes 0838aa7fcfcd ('netfilter: fix netns dependencies with conntrack templates')

Applied, thanks.

I have also appended this chunk, since synproxy is also affected:

net/netfilter/nf_synproxy_core.c static int __net_init synproxy_net_init(struct net *net) · line 359

Quoted 8 lines
net/netfilter/nf_synproxy_core.c +1 -1
@@ -353,7 +353,7 @@ static int __net_init synproxy_net_init(struct net *net)
        int err = -ENOMEM;
 
        ct = nf_ct_tmpl_alloc(net, 0, GFP_KERNEL);
-       if (IS_ERR(ct)) {
+       if (!ct) {
                err = PTR_ERR(ct);
                goto err1;
        }

Does PTR_ERR() implicitly interpret NULL as -ENOMEM? Seems like the fix applied here is a little different from the xt_CT fix.

#5 lore raw
Quoted 18 lines · Joe Stringer
Quoted 17 lines · Pablo Neira Ayuso
Quoted 6 lines · Dan Carpenter

We recently changed this from nf_conntrack_alloc() to nf_ct_tmpl_alloc() so the error handling needs to changed to check for NULL instead of IS_ERR().

Fixes 0838aa7fcfcd ('netfilter: fix netns dependencies with conntrack templates')

Applied, thanks.

I have also appended this chunk, since synproxy is also affected:

net/netfilter/nf_synproxy_core.c +0 -0
@@ -353,7 +353,7 @@ static int __net_init synproxy_net_init(struct net *net)
        int err = -ENOMEM;
 
Quoted 9 lines

net/netfilter/nf_synproxy_core.c static int __net_init synproxy_net_init(struct net *net) · line 359

Quoted 6 lines
net/netfilter/nf_synproxy_core.c +1 -1
        ct = nf_ct_tmpl_alloc(net, 0, GFP_KERNEL);
-       if (IS_ERR(ct)) {
+       if (!ct) {
                err = PTR_ERR(ct);
                goto err1;
        }

Does PTR_ERR() implicitly interpret NULL as -ENOMEM? Seems like the fix applied here is a little different from the xt_CT fix.

Just saw the initialization of err now, but this would be overridden within the error checking statement.

#6 lore raw
Quoted 29 lines · Joe Stringer
Quoted 18 lines · Joe Stringer
Quoted 17 lines · Pablo Neira Ayuso
Quoted 6 lines · Dan Carpenter

We recently changed this from nf_conntrack_alloc() to nf_ct_tmpl_alloc() so the error handling needs to changed to check for NULL instead of IS_ERR().

Fixes 0838aa7fcfcd ('netfilter: fix netns dependencies with conntrack templates')

Applied, thanks.

I have also appended this chunk, since synproxy is also affected:

net/netfilter/nf_synproxy_core.c +0 -0
@@ -353,7 +353,7 @@ static int __net_init synproxy_net_init(struct net *net)
        int err = -ENOMEM;
 
Quoted 9 lines

net/netfilter/nf_synproxy_core.c static int __net_init synproxy_net_init(struct net *net) · line 359

Quoted 6 lines
net/netfilter/nf_synproxy_core.c +1 -1
        ct = nf_ct_tmpl_alloc(net, 0, GFP_KERNEL);
-       if (IS_ERR(ct)) {
+       if (!ct) {
                err = PTR_ERR(ct);
                goto err1;
        }

Does PTR_ERR() implicitly interpret NULL as -ENOMEM? Seems like the fix applied here is a little different from the xt_CT fix.

Quoted 2 lines

Just saw the initialization of err now, but this would be overridden within the error checking statement.

Right, I noticed before pushing out this change, the final applied patch is here:

http://git.kernel.org/cgit/linux/kernel/git/pablo/nf.git/commit/?id727c63612fc582370cf3dc01239d3d239743b5

Let me know if you still have any concern, thanks Joe.

#7 lore raw
Quoted 33 lines · Pablo Neira Ayuso
Quoted 29 lines · Joe Stringer
Quoted 18 lines · Joe Stringer
Quoted 17 lines · Pablo Neira Ayuso
Quoted 6 lines · Dan Carpenter

We recently changed this from nf_conntrack_alloc() to nf_ct_tmpl_alloc() so the error handling needs to changed to check for NULL instead of IS_ERR().

Fixes 0838aa7fcfcd ('netfilter: fix netns dependencies with conntrack templates')

Applied, thanks.

I have also appended this chunk, since synproxy is also affected:

net/netfilter/nf_synproxy_core.c +0 -0
@@ -353,7 +353,7 @@ static int __net_init synproxy_net_init(struct net *net)
        int err = -ENOMEM;
 
Quoted 9 lines

net/netfilter/nf_synproxy_core.c static int __net_init synproxy_net_init(struct net *net) · line 359

Quoted 6 lines
net/netfilter/nf_synproxy_core.c +1 -1
        ct = nf_ct_tmpl_alloc(net, 0, GFP_KERNEL);
-       if (IS_ERR(ct)) {
+       if (!ct) {
                err = PTR_ERR(ct);
                goto err1;
        }

Does PTR_ERR() implicitly interpret NULL as -ENOMEM? Seems like the fix applied here is a little different from the xt_CT fix.

Quoted 2 lines

Just saw the initialization of err now, but this would be overridden within the error checking statement.

Quoted 6 lines

Right, I noticed before pushing out this change, the final applied patch is here:

http://git.kernel.org/cgit/linux/kernel/git/pablo/nf.git/commit/?id727c63612fc582370cf3dc01239d3d239743b5

Let me know if you still have any concern, thanks Joe.

Looks fine. Apologies for the noise.