Skip to content

Commit 4427002

Browse files
committed
netfilter: nf_tables: fix spurious set element insertion failure
JIRA: https://issues.redhat.com/browse/RHEL-1720 JIRA: https://issues.redhat.com/browse/RHEL-1721 Upstream Status: commit ddbd8be commit ddbd8be Author: Florian Westphal <fw@strlen.de> Date: Thu Jul 20 00:29:58 2023 +0200 netfilter: nf_tables: fix spurious set element insertion failure On some platforms there is a padding hole in the nft_verdict structure, between the verdict code and the chain pointer. On element insertion, if the new element clashes with an existing one and NLM_F_EXCL flag isn't set, we want to ignore the -EEXIST error as long as the data associated with duplicated element is the same as the existing one. The data equality check uses memcmp. For normal data (NFT_DATA_VALUE) this works fine, but for NFT_DATA_VERDICT padding area leads to spurious failure even if the verdict data is the same. This then makes the insertion fail with 'already exists' error, even though the new "key : data" matches an existing entry and userspace told the kernel that it doesn't want to receive an error indication. Fixes: c016c7e ("netfilter: nf_tables: honor NLM_F_EXCL flag in set element insertion") Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Florian Westphal <fwestpha@redhat.com>
1 parent 854ec83 commit 4427002

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10156,6 +10156,9 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,
1015610156

1015710157
if (!tb[NFTA_VERDICT_CODE])
1015810158
return -EINVAL;
10159+
10160+
/* zero padding hole for memcmp */
10161+
memset(data, 0, sizeof(*data));
1015910162
data->verdict.code = ntohl(nla_get_be32(tb[NFTA_VERDICT_CODE]));
1016010163

1016110164
switch (data->verdict.code) {

0 commit comments

Comments
 (0)