提交 9ec4c9eb 编写于 作者: P Pablo Neira Ayuso 提交者: Zheng Zengkai

netfilter: nf_tables: missing error reporting for not selected expressions

stable inclusion
from stable-5.10.43
commit 316de9a88c83c672c18d35bd76034d84e3769fe9
bugzilla: 109284
CVE: NA

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

commit c781471d upstream.

Sometimes users forget to turn on nftables extensions from Kconfig that
they need. In such case, the error reporting from userspace is
misleading:

 $ sudo nft add rule x y counter
 Error: Could not process rule: No such file or directory
 add rule x y counter
 ^^^^^^^^^^^^^^^^^^^^

Add missing NL_SET_BAD_ATTR() to provide a hint:

 $ nft add rule x y counter
 Error: Could not process rule: No such file or directory
 add rule x y counter
              ^^^^^^^

Fixes: 83d9dcba ("netfilter: nf_tables: extended netlink error reporting for expressions")
Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 3c5fe07e
...@@ -3263,8 +3263,10 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk, ...@@ -3263,8 +3263,10 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk,
if (n == NFT_RULE_MAXEXPRS) if (n == NFT_RULE_MAXEXPRS)
goto err1; goto err1;
err = nf_tables_expr_parse(&ctx, tmp, &info[n]); err = nf_tables_expr_parse(&ctx, tmp, &info[n]);
if (err < 0) if (err < 0) {
NL_SET_BAD_ATTR(extack, tmp);
goto err1; goto err1;
}
size += info[n].ops->size; size += info[n].ops->size;
n++; n++;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册