Skip to content

Commit a2c9ebd

Browse files
pvts-matPlaidCat
authored andcommitted
netfilter: nf_tables: Reject tables of unsupported family
jira VULN-8162 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 0e0e088 commit a2c9ebd

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
@@ -1003,6 +1003,30 @@ static int nft_objname_hash_cmp(struct rhashtable_compare_arg *arg,
10031003
return strcmp(obj->key.name, k->name);
10041004
}
10051005

1006+
static bool nft_supported_family(u8 family)
1007+
{
1008+
return false
1009+
#ifdef CONFIG_NF_TABLES_INET
1010+
|| family == NFPROTO_INET
1011+
#endif
1012+
#ifdef CONFIG_NF_TABLES_IPV4
1013+
|| family == NFPROTO_IPV4
1014+
#endif
1015+
#ifdef CONFIG_NF_TABLES_ARP
1016+
|| family == NFPROTO_ARP
1017+
#endif
1018+
#ifdef CONFIG_NF_TABLES_NETDEV
1019+
|| family == NFPROTO_NETDEV
1020+
#endif
1021+
#if IS_ENABLED(CONFIG_NF_TABLES_BRIDGE)
1022+
|| family == NFPROTO_BRIDGE
1023+
#endif
1024+
#ifdef CONFIG_NF_TABLES_IPV6
1025+
|| family == NFPROTO_IPV6
1026+
#endif
1027+
;
1028+
}
1029+
10061030
static int nf_tables_newtable(struct net *net, struct sock *nlsk,
10071031
struct sk_buff *skb, const struct nlmsghdr *nlh,
10081032
const struct nlattr * const nla[],
@@ -1017,6 +1041,9 @@ static int nf_tables_newtable(struct net *net, struct sock *nlsk,
10171041
struct nft_ctx ctx;
10181042
int err;
10191043

1044+
if (!nft_supported_family(family))
1045+
return -EOPNOTSUPP;
1046+
10201047
lockdep_assert_held(&net->nft_commit_mutex);
10211048
attr = nla[NFTA_TABLE_NAME];
10221049
table = nft_table_lookup(net, attr, family, genmask);

0 commit comments

Comments
 (0)