Skip to content

Commit f1f09f0

Browse files
committed
netfilter: nf_tables: Reject tables of unsupported family
jira VULN-8892 jira VULN-8893 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 7f76457 commit f1f09f0

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

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

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

0 commit comments

Comments
 (0)