[Devel] [PATCH RH7] ms/netfilter: nft_compat: check extension hook mask only if set

Alexander Mikhalitsyn alexander.mikhalitsyn at virtuozzo.com
Wed Feb 24 20:11:51 MSK 2021


From: Pablo Neira Ayuso <pablo at netfilter.org>

If the x_tables extension comes with no hook mask, skip this validation.

Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>
(cherry picked from commit f7fb77fc12352d15180dc3c08ffba10573d5167d)

This patch fixes start of weavenet CNI pod of k8s
https://jira.sw.ru/browse/PSBM-125884
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
---
 net/netfilter/nft_compat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 4a875378c40d..de51ae31144e 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -309,7 +309,7 @@ static int nft_target_validate(const struct nft_ctx *ctx,
 		const struct nf_hook_ops *ops = &basechain->ops[0];
 
 		hook_mask = 1 << ops->hooknum;
-		if (!(hook_mask & target->hooks))
+		if (target->hooks && !(hook_mask & target->hooks))
 			return -EINVAL;
 
 		ret = nft_compat_chain_validate_dependency(target->table,
@@ -493,7 +493,7 @@ static int nft_match_validate(const struct nft_ctx *ctx,
 		const struct nf_hook_ops *ops = &basechain->ops[0];
 
 		hook_mask = 1 << ops->hooknum;
-		if (!(hook_mask & match->hooks))
+		if (match->hooks && !(hook_mask & match->hooks))
 			return -EINVAL;
 
 		ret = nft_compat_chain_validate_dependency(match->table,
-- 
2.28.0



More information about the Devel mailing list