]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: nf_tables: do not allow RULE_ID to refer to another chain
authorThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Tue, 9 Aug 2022 17:01:48 +0000 (14:01 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:17:27 +0000 (11:17 +0200)
commitfb64f59529e185faf1843592d4df0aaf6df46da7
tree7a2620134e8d6ceeca35e9e63d4824b7060d6505
parent0708f4a671b939e7f56252c4f1f81e7a884bc620
netfilter: nf_tables: do not allow RULE_ID to refer to another chain

commit a5a1fd0d44c7ab2fd3d30248c7adb031c667c08a upstream.

When doing lookups for rules on the same batch by using its ID, a rule from
a different chain can be used. If a rule is added to a chain but tries to
be positioned next to a rule from a different chain, it will be linked to
chain2, but the use counter on chain1 would be the one to be incremented.

When looking for rules by ID, use the chain that was used for the lookup by
name. The chain used in the context copied to the transaction needs to
match that same chain. That way, struct nft_rule does not need to get
enlarged with another member.

Fixes: 923354fe5352 ("netfilter: nf_tables: add NFTA_RULE_ID attribute")
Fixes: 3c095cb5288d ("netfilter: nf_tables: Support RULE_ID reference in new rule")
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/netfilter/nf_tables_api.c