Skip to content

Commit 351c22a

Browse files
committed
netfilter: nf_tables: Reject tables of unsupported family
jira VULN-8894 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: Brett Mastbergen <[email protected]>
1 parent 99ce2db commit 351c22a

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
@@ -1076,6 +1076,30 @@ static int nft_objname_hash_cmp(struct rhashtable_compare_arg *arg,
10761076
return strcmp(obj->key.name, k->name);
10771077
}
10781078

1079+
static bool nft_supported_family(u8 family)
1080+
{
1081+
return false
1082+
#ifdef CONFIG_NF_TABLES_INET
1083+
|| family == NFPROTO_INET
1084+
#endif
1085+
#ifdef CONFIG_NF_TABLES_IPV4
1086+
|| family == NFPROTO_IPV4
1087+
#endif
1088+
#ifdef CONFIG_NF_TABLES_ARP
1089+
|| family == NFPROTO_ARP
1090+
#endif
1091+
#ifdef CONFIG_NF_TABLES_NETDEV
1092+
|| family == NFPROTO_NETDEV
1093+
#endif
1094+
#if IS_ENABLED(CONFIG_NF_TABLES_BRIDGE)
1095+
|| family == NFPROTO_BRIDGE
1096+
#endif
1097+
#ifdef CONFIG_NF_TABLES_IPV6
1098+
|| family == NFPROTO_IPV6
1099+
#endif
1100+
;
1101+
}
1102+
10791103
static int nf_tables_newtable(struct net *net, struct sock *nlsk,
10801104
struct sk_buff *skb, const struct nlmsghdr *nlh,
10811105
const struct nlattr * const nla[],
@@ -1090,6 +1114,9 @@ static int nf_tables_newtable(struct net *net, struct sock *nlsk,
10901114
struct nft_ctx ctx;
10911115
int err;
10921116

1117+
if (!nft_supported_family(family))
1118+
return -EOPNOTSUPP;
1119+
10931120
lockdep_assert_held(&net->nft_commit_mutex);
10941121
attr = nla[NFTA_TABLE_NAME];
10951122
table = nft_table_lookup(net, attr, family, genmask);

0 commit comments

Comments
 (0)