Skip to content

Commit 8c46207

Browse files
pvts-matPlaidCat
authored andcommitted
netfilter: nf_tables: Reject tables of unsupported family
jira VULN-7622 cve CVE-2023-6040 commit-author Phil Sutter <[email protected]> commit f1082dd upstream-diff | 1. The `CONFIG_NF_TABLES_NETDEV' case removed because that option is not even available in the `ciqcbr7_9' yet. 2. All table type CONFIGs wrapped in `IS_ENABLED(...)' macro instead of just `CONFIG_NF_TABLES_BRIDGE' because all of them are of type "tristate" in `ciqcbr7_9', unlike in the newer kernels where they are "bool" and a simple #ifdef is sufficient. 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 f946730 commit 8c46207

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,27 @@ static int nf_tables_updtable(struct nft_ctx *ctx)
702702
return ret;
703703
}
704704

705+
static bool nft_supported_family(u8 family)
706+
{
707+
return false
708+
#if IS_ENABLED(CONFIG_NF_TABLES_INET)
709+
|| family == NFPROTO_INET
710+
#endif
711+
#if IS_ENABLED(CONFIG_NF_TABLES_IPV4)
712+
|| family == NFPROTO_IPV4
713+
#endif
714+
#if IS_ENABLED(CONFIG_NF_TABLES_ARP)
715+
|| family == NFPROTO_ARP
716+
#endif
717+
#if IS_ENABLED(CONFIG_NF_TABLES_BRIDGE)
718+
|| family == NFPROTO_BRIDGE
719+
#endif
720+
#if IS_ENABLED(CONFIG_NF_TABLES_IPV6)
721+
|| family == NFPROTO_IPV6
722+
#endif
723+
;
724+
}
725+
705726
static int nf_tables_newtable(struct net *net, struct sock *nlsk,
706727
struct sk_buff *skb, const struct nlmsghdr *nlh,
707728
const struct nlattr * const nla[])
@@ -715,6 +736,9 @@ static int nf_tables_newtable(struct net *net, struct sock *nlsk,
715736
struct nft_ctx ctx;
716737
int err;
717738

739+
if (!nft_supported_family(family))
740+
return -EOPNOTSUPP;
741+
718742
afi = nf_tables_afinfo_lookup(net, family, true);
719743
if (IS_ERR(afi))
720744
return PTR_ERR(afi);

0 commit comments

Comments
 (0)