Skip to content

Commit b62cb6a

Browse files
author
Paolo Abeni
committed
Merge tag 'nf-24-06-27' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf
Pablo Neira Ayuso says: ==================== Netfilter fixes for net The following patchset contains two Netfilter fixes for net: Patch #1 fixes CONFIG_SYSCTL=n for a patch coming in the previous PR to move the sysctl toggle to enable SRv6 netfilter hooks from nf_conntrack to the core, from Jianguo Wu. Patch #2 fixes a possible pointer leak to userspace due to insufficient validation of NFT_DATA_VALUE. Linus found this pointer leak to userspace via zdi-disclosures@ and forwarded the notice to Netfilter maintainers, he appears as reporter because whoever found this issue never approached Netfilter maintainers neither via security@ nor in private. netfilter pull request 24-06-27 * tag 'nf-24-06-27' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: netfilter: nf_tables: fully validate NFT_DATA_VALUE on store to data registers netfilter: fix undefined reference to 'netfilter_lwtunnel_*' when CONFIG_SYSCTL=n ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 1864b82 + 7931d32 commit b62cb6a

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,11 @@ static inline void *nft_set_priv(const struct nft_set *set)
619619
return (void *)set->data;
620620
}
621621

622+
static inline enum nft_data_types nft_set_datatype(const struct nft_set *set)
623+
{
624+
return set->dtype == NFT_DATA_VERDICT ? NFT_DATA_VERDICT : NFT_DATA_VALUE;
625+
}
626+
622627
static inline bool nft_set_gc_is_pending(const struct nft_set *s)
623628
{
624629
return refcount_read(&s->refs) != 1;

net/netfilter/nf_hooks_lwtunnel.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,7 @@ void netfilter_lwtunnel_fini(void)
117117
{
118118
unregister_pernet_subsys(&nf_lwtunnel_net_ops);
119119
}
120+
#else
121+
int __init netfilter_lwtunnel_init(void) { return 0; }
122+
void netfilter_lwtunnel_fini(void) {}
120123
#endif /* CONFIG_SYSCTL */

net/netfilter/nf_tables_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5740,8 +5740,7 @@ static int nf_tables_fill_setelem(struct sk_buff *skb,
57405740

57415741
if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA) &&
57425742
nft_data_dump(skb, NFTA_SET_ELEM_DATA, nft_set_ext_data(ext),
5743-
set->dtype == NFT_DATA_VERDICT ? NFT_DATA_VERDICT : NFT_DATA_VALUE,
5744-
set->dlen) < 0)
5743+
nft_set_datatype(set), set->dlen) < 0)
57455744
goto nla_put_failure;
57465745

57475746
if (nft_set_ext_exists(ext, NFT_SET_EXT_EXPRESSIONS) &&
@@ -11073,6 +11072,9 @@ static int nft_validate_register_store(const struct nft_ctx *ctx,
1107311072

1107411073
return 0;
1107511074
default:
11075+
if (type != NFT_DATA_VALUE)
11076+
return -EINVAL;
11077+
1107611078
if (reg < NFT_REG_1 * NFT_REG_SIZE / NFT_REG32_SIZE)
1107711079
return -EINVAL;
1107811080
if (len == 0)
@@ -11081,8 +11083,6 @@ static int nft_validate_register_store(const struct nft_ctx *ctx,
1108111083
sizeof_field(struct nft_regs, data))
1108211084
return -ERANGE;
1108311085

11084-
if (data != NULL && type != NFT_DATA_VALUE)
11085-
return -EINVAL;
1108611086
return 0;
1108711087
}
1108811088
}

net/netfilter/nft_lookup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ static int nft_lookup_init(const struct nft_ctx *ctx,
132132
return -EINVAL;
133133

134134
err = nft_parse_register_store(ctx, tb[NFTA_LOOKUP_DREG],
135-
&priv->dreg, NULL, set->dtype,
135+
&priv->dreg, NULL,
136+
nft_set_datatype(set),
136137
set->dlen);
137138
if (err < 0)
138139
return err;

0 commit comments

Comments
 (0)