Skip to content

Commit 2dd2826

Browse files
pvts-matPlaidCat
authored andcommitted
netfilter: nf_tables: Reject tables of unsupported family
jira VULN-8164 cve CVE-2023-6040 commit-author Phil Sutter <[email protected]> commit f1082dd An nftables family is merely a hollow container, its family just a number and such not reliant on compile-time options other than nftables support itself. Add an artificial check so attempts at using a family the kernel can't support fail as early as possible. This helps user space detect kernels which lack e.g. NFPROTO_INET. Signed-off-by: Phil Sutter <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> (cherry picked from commit f1082dd) Signed-off-by: Marcin Wcisło <[email protected]>
1 parent f85f16c commit 2dd2826

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,30 @@ static int nft_objname_hash_cmp(struct rhashtable_compare_arg *arg,
11641164
return strcmp(obj->key.name, k->name);
11651165
}
11661166

1167+
static bool nft_supported_family(u8 family)
1168+
{
1169+
return false
1170+
#ifdef CONFIG_NF_TABLES_INET
1171+
|| family == NFPROTO_INET
1172+
#endif
1173+
#ifdef CONFIG_NF_TABLES_IPV4
1174+
|| family == NFPROTO_IPV4
1175+
#endif
1176+
#ifdef CONFIG_NF_TABLES_ARP
1177+
|| family == NFPROTO_ARP
1178+
#endif
1179+
#ifdef CONFIG_NF_TABLES_NETDEV
1180+
|| family == NFPROTO_NETDEV
1181+
#endif
1182+
#if IS_ENABLED(CONFIG_NF_TABLES_BRIDGE)
1183+
|| family == NFPROTO_BRIDGE
1184+
#endif
1185+
#ifdef CONFIG_NF_TABLES_IPV6
1186+
|| family == NFPROTO_IPV6
1187+
#endif
1188+
;
1189+
}
1190+
11671191
static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info,
11681192
const struct nlattr * const nla[])
11691193
{
@@ -1178,6 +1202,9 @@ static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info,
11781202
u32 flags = 0;
11791203
int err;
11801204

1205+
if (!nft_supported_family(family))
1206+
return -EOPNOTSUPP;
1207+
11811208
lockdep_assert_held(&nft_net->commit_mutex);
11821209
attr = nla[NFTA_TABLE_NAME];
11831210
table = nft_table_lookup(net, attr, family, genmask,

0 commit comments

Comments
 (0)