]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
netfilter: nf_tables: report use refcount overflow
authorPablo Neira Ayuso <pablo@netfilter.org>
Sat, 12 Aug 2023 22:06:55 +0000 (00:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Aug 2023 16:22:03 +0000 (18:22 +0200)
commitb757ef99df3988c61e382daef48fd83ce447f2b7
tree1ebcb9985024c3c27b36832e868b9b2e2f319539
parent9bdbbcf9d148aebd686aabe13e80e1e4e8610c60
netfilter: nf_tables: report use refcount overflow

commit 1689f25924ada8fe14a4a82c38925d04994c7142 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.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