Commit 8c3b8df6 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso Committed by sanglipeng1
Browse files

netfilter: nf_tables: reject NFT_SET_CONCAT with not field length description

stable inclusion
from stable-v5.10.209
commit 00a86f81c80e0904a3005ff9e333f4185593b59b
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9U3NW

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=00a86f81c80e0904a3005ff9e333f4185593b59b



--------------------------------

[ Upstream commit 113661e07460a6604aacc8ae1b23695a89e7d4b3 ]

It is still possible to set on the NFT_SET_CONCAT flag by specifying a
set size and no field description, report EINVAL in such case.

Fixes: 1b6345d4 ("netfilter: nf_tables: check NFT_SET_CONCAT flag if field_count is specified")
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng1 <sanglipeng1@jd.com>
parent bf072247
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -4502,11 +4502,15 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk,
		if (err < 0)
			return err;

		if (desc.field_count > 1 && !(flags & NFT_SET_CONCAT))
		if (desc.field_count > 1) {
			if (!(flags & NFT_SET_CONCAT))
				return -EINVAL;
		} else if (flags & NFT_SET_CONCAT) {
			return -EINVAL;
		}
	} else if (flags & NFT_SET_CONCAT) {
		return -EINVAL;
	}

	if (nla[NFTA_SET_EXPR])
		desc.expr = true;