netfilter: nft_compat: fix crash when related match/target module is removed
We "cache" the loaded match/target modules and reuse them, but when the
modules are removed, we still point to them. Then we may end up with
invalid memory references when using iptables-compat to add rules later.
Input the following commands will reproduce the kernel crash:
# iptables-compat -A INPUT -j LOG
# iptables-compat -D INPUT -j LOG
# rmmod xt_LOG
# iptables-compat -A INPUT -j LOG
BUG: unable to handle kernel paging request at
ffffffffa05a9010
IP: [<
ffffffff813f783e>] strcmp+0xe/0x30
Call Trace:
[<
ffffffffa05acc43>] nft_target_select_ops+0x83/0x1f0 [nft_compat]
[<
ffffffffa058a177>] nf_tables_expr_parse+0x147/0x1f0 [nf_tables]
[<
ffffffffa058e541>] nf_tables_newrule+0x301/0x810 [nf_tables]
[<
ffffffff8141ca00>] ? nla_parse+0x20/0x100
[<
ffffffffa057fa8f>] nfnetlink_rcv+0x33f/0x53d [nfnetlink]
[<
ffffffffa057f94b>] ? nfnetlink_rcv+0x1fb/0x53d [nfnetlink]
[<
ffffffff817116b8>] netlink_unicast+0x178/0x220
[<
ffffffff81711a5b>] netlink_sendmsg+0x2fb/0x3a0
[<
ffffffff816b7fc8>] sock_sendmsg+0x38/0x50
[<
ffffffff816b8a7e>] ___sys_sendmsg+0x28e/0x2a0
[<
ffffffff816bcb7e>] ? release_sock+0x1e/0xb0
[<
ffffffff81804ac5>] ? _raw_spin_unlock_bh+0x35/0x40
[<
ffffffff816bcbe2>] ? release_sock+0x82/0xb0
[<
ffffffff816b93d4>] __sys_sendmsg+0x54/0x90
[<
ffffffff816b9422>] SyS_sendmsg+0x12/0x20
[<
ffffffff81805172>] entry_SYSCALL_64_fastpath+0x1a/0xa9
So when nobody use the related match/target module, there's no need to
"cache" it. And nft_[match|target]_release are useless anymore, remove
them.
Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>