提交 ee8628e1 编写于 作者: F Florian Westphal 提交者: Yongqiang Liu

netfilter: nf_tables: fix null deref due to zeroed list head

stable inclusion
from stable-v4.19.256
commit d3f409c375490a86d342eae1d0f6271d12dc19d0
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I6IK9U
CVE: CVE-2023-1095

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=d3f409c375490a86d342eae1d0f6271d12dc19d0

--------------------------------

commit 58007785 upstream.

In nf_tables_updtable, if nf_tables_table_enable returns an error,
nft_trans_destroy is called to free the transaction object.

nft_trans_destroy() calls list_del(), but the transaction was never
placed on a list -- the list head is all zeroes, this results in
a null dereference:

BUG: KASAN: null-ptr-deref in nft_trans_destroy+0x26/0x59
Call Trace:
 nft_trans_destroy+0x26/0x59
 nf_tables_newtable+0x4bc/0x9bc
 [..]

Its sane to assume that nft_trans_destroy() can be called
on the transaction object returned by nft_trans_alloc(), so
make sure the list head is initialised.

Fixes: 55dd6f93 ("netfilter: nf_tables: use new transaction infrastructure to handle table")
Reported-by: Nmingi cho <mgcho.minic@gmail.com>
Signed-off-by: NFlorian Westphal <fw@strlen.de>
Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
Reviewed-by: NYue Haibing <yuehaibing@huawei.com>
Reviewed-by: NWang Weiyang <wangweiyang2@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 e533d312
...@@ -96,6 +96,7 @@ static struct nft_trans *nft_trans_alloc_gfp(const struct nft_ctx *ctx, ...@@ -96,6 +96,7 @@ static struct nft_trans *nft_trans_alloc_gfp(const struct nft_ctx *ctx,
if (trans == NULL) if (trans == NULL)
return NULL; return NULL;
INIT_LIST_HEAD(&trans->list);
trans->msg_type = msg_type; trans->msg_type = msg_type;
trans->ctx = *ctx; trans->ctx = *ctx;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册