netfilter: nf_tables: report use refcount overflow
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 28 Jun 2023 14:24:27 +0000 (16:24 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 5 Jul 2023 12:42:15 +0000 (14:42 +0200)
commit1689f25924ada8fe14a4a82c38925d04994c7142
tree41cb3c65a36016777f7f148fd8c4fa1eca5601ff
parentc451410ca7e3d8eeb31d141fc20c200e21754ba4
netfilter: nf_tables: report use refcount overflow

Overflow use refcount checks are not complete.

Add helper function to deal with object reference counter tracking.
Report -EMFILE in case UINT_MAX is reached.

nft_use_dec() splats in case that reference counter underflows,
which should not ever happen.

Add nft_use_inc_restore() and nft_use_dec_restore() which are used
to restore reference counter from error and abort paths.

Use u32 in nft_flowtable and nft_object since helper functions cannot
work on bitfields.

Remove the few early incomplete checks now that the helper functions
are in place and used to check for refcount overflow.

Fixes: 96518518cc41 ("netfilter: add nftables")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/netfilter/nf_tables.h
net/netfilter/nf_tables_api.c
net/netfilter/nft_flow_offload.c
net/netfilter/nft_immediate.c
net/netfilter/nft_objref.c