Skip to contentSkip to conversation

check_entry & module_refcount

PATCH Applied Dmitry Mishin 3 participants 6 messages Sep 4, 2006 – Sep 7, 2006

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

Hello, all!

Does anybody know why there is no module_put() on the error way after failed standard_check() call in the check_entry() function? Previous xt_find_target() calls try_module_get() for all targets, without special checks for standard_target.

If it is a bug, patch over net-2.6.19 is below.

--

 ip_tables.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/netfilter/ip_tables.c renamed from net/ipv4/netfilter/ip_tables.c.err +1 -1
@@ -573,7 +573,7 @@
 	if (t->u.kernel.target == &ipt_standard_target) {
 		if (!standard_check(t, size)) {
 			ret = -EINVAL;
-			goto cleanup_matches;
+			goto err;
 		}
 	} else if (t->u.kernel.target->checkentry
 		   && !t->u.kernel.target->checkentry(name, e, target, t->data,
#1 lore raw
Quoted 6 lines · Dmitry Mishin

Hello, all!

Does anybody know why there is no module_put() on the error way after failed standard_check() call in the check_entry() function? Previous xt_find_target() calls try_module_get() for all targets, without special checks for standard_target.

The standard target doesn't have a module reference, so the counter isn't really increased. While rules are present the tables have references to ip_tables anyway, so its not needed.

#2 lore raw
In reply to Dmitry Mishin

Hello,

From: Dmitry Mishin <[email protected]>
Date: Mon, 4 Sep 2006 16:17:39 +0400

Quoted 6 lines

Hello, all!

Does anybody know why there is no module_put() on the error way after failed standard_check() call in the check_entry() function? Previous xt_find_target() calls try_module_get() for all targets, without special checks for standard_target.

standard target is build in ip_tables.ko which has check_entry(), and check_entry() cannot fail to get the module.

Then we doesn't set standard_target.me and try_module_{get,put}() do nothing as result.

I think, the author thought that there is no necessary to call module_put() there.

Quoted 1 line

If it is a bug, patch over net-2.6.19 is below.

This is not bug but cleanup. try_get_module() is called anyway, so calling put_module() on error is logically good, I think.

BTW, This can apply to ip6_tables and arp_tables, too.

-- Yasuyuki Kozakai

#3 lore raw
Quoted 10 lines · Yasuyuki KOZAKAI

Hello,

From: Dmitry Mishin <[email protected]>
Date: Mon, 4 Sep 2006 16:17:39 +0400

Quoted 1 line

If it is a bug, patch over net-2.6.19 is below.

This is not bug but cleanup. try_get_module() is called anyway, so calling put_module() on error is logically good, I think.

Agreed. Dmitry, you can send a patch which changes this for ip6_tables and arp_tables as well?

#4 lore raw

small check_entry & module_refcount cleanup

While standard_target has target->me == NULL, module_put() should be called for it as for others, because there were try_module_get() before.

net/ipv4/netfilter/arp_tables.c +1 -1
index 4f10b06..0e899f0 100644
@@ -487,7 +487,7 @@ static inline int check_entry(struct arp
 	if (t->u.kernel.target == &arpt_standard_target) {
 		if (!standard_check(t, size)) {
 			ret = -EINVAL;
-			goto out;
+			goto err;
 		}
 	} else if (t->u.kernel.target->checkentry
 		   && !t->u.kernel.target->checkentry(name, e, target, t->data,
net/ipv4/netfilter/ip_tables.c +1 -1
index a0f3680..38e1e4f 100644
@@ -573,7 +573,7 @@ check_entry(struct ipt_entry *e, const c
 	if (t->u.kernel.target == &ipt_standard_target) {
 		if (!standard_check(t, size)) {
 			ret = -EINVAL;
-			goto cleanup_matches;
+			goto err;
 		}
 	} else if (t->u.kernel.target->checkentry
 		   && !t->u.kernel.target->checkentry(name, e, target, t->data,
net/ipv6/netfilter/ip6_tables.c +1 -1
index d1c3153..3becbb5 100644
@@ -613,7 +613,7 @@ check_entry(struct ip6t_entry *e, const 
 	if (t->u.kernel.target == &ip6t_standard_target) {
 		if (!standard_check(t, size)) {
 			ret = -EINVAL;
-			goto cleanup_matches;
+			goto err;
 		}
 	} else if (t->u.kernel.target->checkentry
 		   && !t->u.kernel.target->checkentry(name, e, target, t->data,
#5 lore raw

Re: small check_entry & module_refcount cleanup

Quoted 2 lines · Dmitry Mishin

While standard_target has target->me == NULL, module_put() should be called for it as for others, because there were try_module_get() before.

Applied, thanks Dmitry.