[PATCH 3/3] netfilter: nf_tables: do not allow RULE_ID to refer to another chain
authorThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Tue, 26 Jul 2022 17:30:27 +0000 (14:30 -0300)
committerSalvatore Bonaccorso <carnil@debian.org>
Wed, 10 Aug 2022 18:11:48 +0000 (19:11 +0100)
commit20b27e149656e64aa8cc4b543dabec48872231de
tree572bacffccd171ea631009a1b8d848d62ea4042e
parente24bd04e5a0322819d01e0838404039eaa096724
[PATCH 3/3] netfilter: nf_tables: do not allow RULE_ID to refer to another chain

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: 1a94e38d254b ("netfilter: nf_tables: add NFTA_RULE_ID attribute")
Fixes: 75dd48e2e420 ("netfilter: nf_tables: Support RULE_ID reference in new rule")
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name netfilter-nf_tables-do-not-allow-RULE_ID-to-refer-to.patch
net/netfilter/nf_tables_api.c