netfilter: nf_tables: Fix entries val in rule reset audit log
authorPhil Sutter <phil@nwl.cc>
Wed, 13 Sep 2023 13:51:36 +0000 (15:51 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 13 Sep 2023 19:57:50 +0000 (21:57 +0200)
commit7fb818f248cff996180b7cdcdcb86b6b4f6e44e2
tree6b5cda6709441c06f1cbf075770f59131c9183d8
parent4908d5af16676b9d2901830551c2af911e452524
netfilter: nf_tables: Fix entries val in rule reset audit log

The value in idx and the number of rules handled in that particular
__nf_tables_dump_rules() call is not identical. The former is a cursor
to pick up from if multiple netlink messages are needed, so its value is
ever increasing. Fixing this is not just a matter of subtracting s_idx
from it, though: When resetting rules in multiple chains,
__nf_tables_dump_rules() is called for each and cb->args[0] is not
adjusted in between. Introduce a dedicated counter to record the number
of rules reset in this call in a less confusing way.

While being at it, prevent the direct return upon buffer exhaustion: Any
rules previously dumped into that skb would evade audit logging
otherwise.

Fixes: 9b5ba5c9c5109 ("netfilter: nf_tables: Unbreak audit log reset")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c