Skip to content

Commit fbab0b7

Browse files
committed
netfilter: nf_tables: Reject tables of unsupported family
JIRA: https://issues.redhat.com/browse/RHEL-21420 Upstream Status: commit f1082dd CVE: CVE-2023-6040 commit f1082dd Author: Phil Sutter <[email protected]> Date: Wed Feb 16 15:55:38 2022 +0100 netfilter: nf_tables: Reject tables of unsupported family 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]> Signed-off-by: Florian Westphal <[email protected]>
1 parent 7a4b0a4 commit fbab0b7

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
@@ -1247,6 +1247,30 @@ static int nft_objname_hash_cmp(struct rhashtable_compare_arg *arg,
12471247
return strcmp(obj->key.name, k->name);
12481248
}
12491249

1250+
static bool nft_supported_family(u8 family)
1251+
{
1252+
return false
1253+
#ifdef CONFIG_NF_TABLES_INET
1254+
|| family == NFPROTO_INET
1255+
#endif
1256+
#ifdef CONFIG_NF_TABLES_IPV4
1257+
|| family == NFPROTO_IPV4
1258+
#endif
1259+
#ifdef CONFIG_NF_TABLES_ARP
1260+
|| family == NFPROTO_ARP
1261+
#endif
1262+
#ifdef CONFIG_NF_TABLES_NETDEV
1263+
|| family == NFPROTO_NETDEV
1264+
#endif
1265+
#if IS_ENABLED(CONFIG_NF_TABLES_BRIDGE)
1266+
|| family == NFPROTO_BRIDGE
1267+
#endif
1268+
#ifdef CONFIG_NF_TABLES_IPV6
1269+
|| family == NFPROTO_IPV6
1270+
#endif
1271+
;
1272+
}
1273+
12501274
static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info,
12511275
const struct nlattr * const nla[])
12521276
{
@@ -1261,6 +1285,9 @@ static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info,
12611285
u32 flags = 0;
12621286
int err;
12631287

1288+
if (!nft_supported_family(family))
1289+
return -EOPNOTSUPP;
1290+
12641291
lockdep_assert_held(&nft_net->commit_mutex);
12651292
attr = nla[NFTA_TABLE_NAME];
12661293
table = nft_table_lookup(net, attr, family, genmask,

0 commit comments

Comments
 (0)