Commit 29d2b670 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso Committed by Greg Kroah-Hartman

netfilter: nft_compat: fix module refcount underflow

commit 520aa741 upstream.

Feb 12 18:20:42 nfdev kernel: ------------[ cut here ]------------
Feb 12 18:20:42 nfdev kernel: WARNING: CPU: 4 PID: 4359 at kernel/module.c:963 module_put+0x9b/0xba()
Feb 12 18:20:42 nfdev kernel: CPU: 4 PID: 4359 Comm: ebtables-compat Tainted: G        W      3.19.0-rc6+ #43
[...]
Feb 12 18:20:42 nfdev kernel: Call Trace:
Feb 12 18:20:42 nfdev kernel: [<ffffffff815fd911>] dump_stack+0x4c/0x65
Feb 12 18:20:42 nfdev kernel: [<ffffffff8103e6f7>] warn_slowpath_common+0x9c/0xb6
Feb 12 18:20:42 nfdev kernel: [<ffffffff8109919f>] ? module_put+0x9b/0xba
Feb 12 18:20:42 nfdev kernel: [<ffffffff8103e726>] warn_slowpath_null+0x15/0x17
Feb 12 18:20:42 nfdev kernel: [<ffffffff8109919f>] module_put+0x9b/0xba
Feb 12 18:20:42 nfdev kernel: [<ffffffff813ecf7c>] nft_match_destroy+0x45/0x4c
Feb 12 18:20:42 nfdev kernel: [<ffffffff813e683f>] nf_tables_rule_destroy+0x28/0x70
Reported-by: default avatarArturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Tested-by: default avatarArturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2a4e9ebd
...@@ -578,9 +578,13 @@ nft_match_select_ops(const struct nft_ctx *ctx, ...@@ -578,9 +578,13 @@ nft_match_select_ops(const struct nft_ctx *ctx,
struct xt_match *match = nft_match->ops.data; struct xt_match *match = nft_match->ops.data;
if (strcmp(match->name, mt_name) == 0 && if (strcmp(match->name, mt_name) == 0 &&
match->revision == rev && match->family == family) match->revision == rev && match->family == family) {
if (!try_module_get(match->me))
return ERR_PTR(-ENOENT);
return &nft_match->ops; return &nft_match->ops;
} }
}
match = xt_request_find_match(family, mt_name, rev); match = xt_request_find_match(family, mt_name, rev);
if (IS_ERR(match)) if (IS_ERR(match))
...@@ -648,9 +652,13 @@ nft_target_select_ops(const struct nft_ctx *ctx, ...@@ -648,9 +652,13 @@ nft_target_select_ops(const struct nft_ctx *ctx,
struct xt_target *target = nft_target->ops.data; struct xt_target *target = nft_target->ops.data;
if (strcmp(target->name, tg_name) == 0 && if (strcmp(target->name, tg_name) == 0 &&
target->revision == rev && target->family == family) target->revision == rev && target->family == family) {
if (!try_module_get(target->me))
return ERR_PTR(-ENOENT);
return &nft_target->ops; return &nft_target->ops;
} }
}
target = xt_request_find_target(family, tg_name, rev); target = xt_request_find_target(family, tg_name, rev);
if (IS_ERR(target)) if (IS_ERR(target))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment