]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
netfilter: nft_compat: add more restrictions on netlink attributes
authorFlorian Westphal <fw@strlen.de>
Fri, 19 Aug 2022 14:16:07 +0000 (16:16 +0200)
committerFlorian Westphal <fw@strlen.de>
Tue, 20 Jan 2026 15:23:37 +0000 (16:23 +0100)
commitcda26c645946b08f070f20c166d4736767e4a805
tree6d643b6f496667de1594a6e08328de560853402f
parenta4400a5b343d1bc4aa8f685608515413238e7ee2
netfilter: nft_compat: add more restrictions on netlink attributes

As far as I can see nothing bad can happen when NFTA_TARGET/MATCH_NAME
are too large because this calls x_tables helpers which check for the
length, but it seems better to already reject it during netlink parsing.

Rest of the changes avoid silent u8/u16 truncations.

For _TYPE, its expected to be only 1 or 0. In x_tables world, this
variable is set by kernel, for IPT_SO_GET_REVISION_TARGET its 1, for
all others its set to 0.

As older versions of nf_tables permitted any value except 1 to mean 'match',
keep this as-is but sanitize the value for consistency.

Fixes: 0ca743a55991 ("netfilter: nf_tables: add compatibility layer for x_tables")
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nft_compat.c