check_entry & module_refcount
Subsystems (2)
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,
Quoted 6 lines · Dmitry Mishin
Hello, all!
Does anybody know why there is no
module_put()on the error way after failedstandard_check()call in thecheck_entry()function? Previousxt_find_target()callstry_module_get()for all targets, without special checks forstandard_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.
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 failedstandard_check()call in thecheck_entry()function? Previousxt_find_target()callstry_module_get()for all targets, without special checks forstandard_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
Quoted 10 lines · Yasuyuki KOZAKAI
Hello,
From: Dmitry Mishin <[email protected]>
Date: Mon, 4 Sep 2006 16:17:39 +0400Quoted 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 callingput_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?
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
@@ -487,7 +487,7 @@ static inline int check_entry(struct arpif (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
@@ -573,7 +573,7 @@ check_entry(struct ipt_entry *e, const cif (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
@@ -613,7 +613,7 @@ check_entry(struct ip6t_entry *e, constif (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,
Patrick McHardy
AppliedRe: small check_entry & module_refcount cleanup
Quoted 2 lines · Dmitry Mishin
While
standard_targethastarget->me== NULL,module_put()should be called for it as for others, because there weretry_module_get()before.
Applied, thanks Dmitry.