]> git.ipfire.org Git - thirdparty/nftables.git/commit
meta: stash context statement length when generating payload/meta dependency
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 18 Jul 2023 21:10:01 +0000 (23:10 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 19 Jul 2023 18:06:34 +0000 (20:06 +0200)
commit5f1676ac9f1aeb36d7695c3c354dade013a1e4f3
tree35af0d12e861771e2f30107f1c79ed78c6dd9ce3
parentae1f506b5b0925dfe07215876f010dd087785ca9
meta: stash context statement length when generating payload/meta dependency

... meta mark set ip dscp

generates an implicit dependency from the inet family to match on meta
nfproto ip.

The length of this implicit expression is incorrectly adjusted to the
statement length, ie. relational to compare meta nfproto takes 4 bytes
instead of 1 byte. The evaluation of 'ip dscp' under the meta mark
statement triggers this implicit dependency which should not consider
the context statement length since it is added before the statement
itself.

This problem shows when listing the ruleset, since netlink_parse_cmp()
where left->len < right->len, hence handling the implicit dependency as
a concatenation, but it is actually a bug in the evaluation step that
leads to incorrect bytecode.

Fixes: 3c64ea7995cb ("evaluate: honor statement length in integer evaluation")
Fixes: edecd58755a8 ("evaluate: support shifts larger than the width of the left operand")
Tested-by: Brian Davidson <davidson.brian@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/payload.c
tests/py/inet/meta.t
tests/py/inet/meta.t.json
tests/py/inet/meta.t.payload