]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netfilter: nft_osf: restrict osf to ipv4, ipv6 and inet families
authorPablo Neira Ayuso <pablo@netfilter.org>
Sun, 21 Aug 2022 14:25:07 +0000 (16:25 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 24 Aug 2022 05:43:21 +0000 (07:43 +0200)
As it was originally intended, restrict extension to supported families.

Fixes: 6255f535ba94 ("netfilter: nf_tables: implement Passive OS fingerprint module in nft_osf")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_osf.c

index 0053a697c9316364cb16f3312f30c0bafe26dfb1..89342ccccdccf6a333155e9b841826ff0b4ce7c0 100644 (file)
@@ -115,9 +115,21 @@ static int nft_osf_validate(const struct nft_ctx *ctx,
                            const struct nft_expr *expr,
                            const struct nft_data **data)
 {
-       return nft_chain_validate_hooks(ctx->chain, (1 << NF_INET_LOCAL_IN) |
-                                                   (1 << NF_INET_PRE_ROUTING) |
-                                                   (1 << NF_INET_FORWARD));
+       unsigned int hooks;
+
+       switch (ctx->family) {
+       case NFPROTO_IPV4:
+       case NFPROTO_IPV6:
+       case NFPROTO_INET:
+               hooks = (1 << NF_INET_LOCAL_IN) |
+                       (1 << NF_INET_PRE_ROUTING) |
+                       (1 << NF_INET_FORWARD);
+               break;
+       default:
+               return -EOPNOTSUPP;
+       }
+
+       return nft_chain_validate_hooks(ctx->chain, hooks);
 }
 
 static bool nft_osf_reduce(struct nft_regs_track *track,