[RHEL7,COMMIT] ms/netfilter: nft_compat: check extension hook mask only if set

Submitted by Vasily Averin on Feb. 25, 2021, 10:40 a.m.

Details

Message ID 202102251040.11PAeTWG016386@vz7build.vvs.sw.ru
State New
Series "ms/netfilter: nft_compat: check extension hook mask only if set"
Headers show

Commit Message

Vasily Averin Feb. 25, 2021, 10:40 a.m.
The commit is pushed to "branch-rh7-3.10.0-1160.11.1.vz7.172.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.11.1.vz7.172.17
------>
commit bd895c2a81375fc790aac8b0e3e2871d887a905b
Author: Pablo Neira Ayuso <pablo@netfilter.org>
Date:   Thu Feb 25 13:40:29 2021 +0300

    ms/netfilter: nft_compat: check extension hook mask only if set
    
    If the x_tables extension comes with no hook mask, skip this validation.
    
    Signed-off-by: Pablo Neira Ayuso <pablo@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@virtuozzo.com>
---
 net/netfilter/nft_compat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 4a87537..de51ae3 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,