Received: by 10.213.65.68 with SMTP id h4csp274188imn; Fri, 23 Mar 2018 04:29:12 -0700 (PDT) X-Google-Smtp-Source: AG47ELvIPKkJIqc11sFXVnew5QEExAnM3V/wLnDaWtCepPXf+2gk+pox99drYDtjhtsi1ZTgxKA3 X-Received: by 10.98.141.65 with SMTP id z62mr23892591pfd.129.1521804552707; Fri, 23 Mar 2018 04:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521804552; cv=none; d=google.com; s=arc-20160816; b=c/aA6JSUGul+yI1eBoAwrG32OV8bdANuar8Rgj2kVm+EABVSbr6nkM9XwRpH2zYwwt xt6F+80ZvFJOxLykgf7ytiCW7GUewuPLrr606mxQHqDF9JSPPbMPIMF0yjeh2ZVK3j+F 7hQPZl8SchDgg8XpGDeRnA/xGXDvHLzwqcR/e2kRgRSJl6p7vaJ3wCbMpJB086PDimkb KkeD0E6utW41n/yXj3DRvDdGpVyhkqRgDuZfeA4gqzRju1S0I/e/JkULzX3Axv1RC4PS m2T9rn4rEMs5wLceem3ChF/SSpyNUCqf2R2Jn+CSbtPWPa1H71Tj9DS4Jr4dKagohgC/ LlLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Q3pQB7lrd288VpsLhgsDIC+iNxanG54xqDsm1zE3+WA=; b=Tt4tdGkEeAVF2TknGo+QmlA4vLwJtTnpaUpr7xt07QwvKBF5IrjNu0NN09e9WNqbpA hAc0bx56j4nC/XhizjiFnotYip/NJcNzYlMP7oGcFSVkPa6Ho2kdNefYh+whMKxs9IOi UDmOvH3bFD9mBBFAimRZC3XiK9bEMS1wC56+k6pn/7aqWICdUGALxotkgwLY+skCxT5U M+mzp6Sp57+HZ3uZCDgDUPr6CZ4OyYAOa4CupLuSj9kluluebea/XQmrUtVFb/g9bb/C EHCb8R3/2lSC1nrIVTXJ81JKX+tgLzzYg5XH5CSGxgbi8eUw/CWe9pppf4fvx1WoGOzN 2KkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b23si6594768pfj.151.2018.03.23.04.28.58; Fri, 23 Mar 2018 04:29:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755424AbeCWL2C (ORCPT + 99 others); Fri, 23 Mar 2018 07:28:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41014 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932218AbeCWKGz (ORCPT ); Fri, 23 Mar 2018 06:06:55 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4A6E7CB1; Fri, 23 Mar 2018 10:06:54 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert White , Liping Zhang , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.9 065/177] netfilter: nft_dynset: continue to next expr if _OP_ADD succeeded Date: Fri, 23 Mar 2018 10:53:13 +0100 Message-Id: <20180323094208.206701990@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Liping Zhang [ Upstream commit 277a292835c196894ef895d5e1fd6170bb916f55 ] Currently, after adding the following nft rules: # nft add set x target1 { type ipv4_addr \; flags timeout \;} # nft add rule x y set add ip daddr timeout 1d @target1 counter the counters will always be zero despite of the elements are added to the dynamic set "target1" or not, as we will break the nft expr traversal unconditionally: # nft list ruleset ... set target1 { ... elements = { 8.8.8.8 expires 23h59m53s} } chain output { ... set add ip daddr timeout 1d @target1 counter packets 0 bytes 0 ^ ^ ... } Since we add the elements to the set successfully, we should continue to the next expression. Additionally, if elements are added to "flow table" successfully, we will _always_ continue to the next expr, even if the operation is _OP_ADD. So it's better to keep them to be consistent. Fixes: 22fe54d5fefc ("netfilter: nf_tables: add support for dynamic set updates") Reported-by: Robert White Signed-off-by: Liping Zhang Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nft_dynset.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/net/netfilter/nft_dynset.c +++ b/net/netfilter/nft_dynset.c @@ -82,8 +82,7 @@ static void nft_dynset_eval(const struct nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION)) { timeout = priv->timeout ? : set->timeout; *nft_set_ext_expiration(ext) = jiffies + timeout; - } else if (sexpr == NULL) - goto out; + } if (sexpr != NULL) sexpr->ops->eval(sexpr, regs, pkt); @@ -92,7 +91,7 @@ static void nft_dynset_eval(const struct regs->verdict.code = NFT_BREAK; return; } -out: + if (!priv->invert) regs->verdict.code = NFT_BREAK; }