Received: by 10.213.65.68 with SMTP id h4csp721720imn; Fri, 6 Apr 2018 07:51:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx48OKKC/YW78ZEC+cRCQ0Fd6kq8mqVCzEZQth5qmbm9+NeLBXaCvOYy9rGz2PKTmYL+pIx/m X-Received: by 10.99.120.196 with SMTP id t187mr18128943pgc.149.1523026286190; Fri, 06 Apr 2018 07:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523026286; cv=none; d=google.com; s=arc-20160816; b=h93P4/6n2ST1ed4PLpP69L6YDn1b2RSZo7YBkxT7sGNB1W7l0Twp+yO7EcYqowkvvK fCfCUmjG8xbaUfSphfY4fs7Xb3EM7fTatM/6bjy5w2StIearh6KXmKImvkCNyzgZSRsu 6tZGkQrVMVq1kKUgz2NnW0f6IZd92KmiWqMR3t7v65UScflfKhSn3P5YuA71flkh2xYV 3Nx1SjxtxGPE0SNavZbzNyLtWyzZsUmDUSIlcmwyKjJYTXIDN30n0YqPxQZFp1MzAsLm 5nFSJaX1ToFpDPUh+0BEOxBy0QFFpIX8Ozo1jOubcdORqrnRno/Uzx9WIWDF/qBODoFF 04DQ== 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=HAZv0gP9NWmvT4D2NURExX4uVE3vFnqM0JliS1YsRJs=; b=oZhrUDy8hj2nl9Bo0MFxIme3IFcDEzT/L0i/7RX3Suxmc+6u/cp94UmACa0q8lFe8/ KM3SOBJYtOrwEI3nO7B0fwkWHxTL1gojBXCgEZ00GcLxi4mxn6sRHKmNBWyhfNwLeK0Q GbtlcAbF1YjFiHzzRpbprve+TD58QWHXXug59WSwcO5kM2EVytfiJTVdhHE1NsshyJgA yVDtL+ecV+N8YKYeVieD+mL11A4MydqU9nOflApUZ/IHmSdKqR5uS/Y9DcKWUNUtPwKG +Iss7LeQWkqTOhSb02gUXtkFy7IwUHgmh2ZrTm+gHVqJUtJ/+6dpsyBGhGepZuvnE8KL 7jhg== 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 t16si8138732pfm.150.2018.04.06.07.51.12; Fri, 06 Apr 2018 07:51:26 -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 S1755494AbeDFNdD (ORCPT + 99 others); Fri, 6 Apr 2018 09:33:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57706 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755211AbeDFNdB (ORCPT ); Fri, 6 Apr 2018 09:33:01 -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 989698A5; Fri, 6 Apr 2018 13:33:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nick Desaulniers , Pablo Neira Ayuso , Nathan Chancellor Subject: [PATCH 4.9 016/102] netfilter: nf_nat_h323: fix logical-not-parentheses warning Date: Fri, 6 Apr 2018 15:22:57 +0200 Message-Id: <20180406084333.901636538@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084331.507038179@linuxfoundation.org> References: <20180406084331.507038179@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: Nick Desaulniers commit eee6ebbac18a189ef33d25ea9b8bcae176515e49 upstream. Clang produces the following warning: net/ipv4/netfilter/nf_nat_h323.c:553:6: error: logical not is only applied to the left hand side of this comparison [-Werror,-Wlogical-not-parentheses] if (!set_h225_addr(skb, protoff, data, dataoff, taddr, ^ add parentheses after the '!' to evaluate the comparison first add parentheses around left hand side expression to silence this warning There's not necessarily a bug here, but it's cleaner to return early, ex: if (x) return ... rather than: if (x == 0) ... else return Also added a return code check that seemed to be missing in one instance. Signed-off-by: Nick Desaulniers Signed-off-by: Pablo Neira Ayuso Cc: Nathan Chancellor Signed-off-by: Greg Kroah-Hartman --- net/ipv4/netfilter/nf_nat_h323.c | 57 ++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 27 deletions(-) --- a/net/ipv4/netfilter/nf_nat_h323.c +++ b/net/ipv4/netfilter/nf_nat_h323.c @@ -252,16 +252,16 @@ static int nat_rtp_rtcp(struct sk_buff * if (set_h245_addr(skb, protoff, data, dataoff, taddr, &ct->tuplehash[!dir].tuple.dst.u3, htons((port & htons(1)) ? nated_port + 1 : - nated_port)) == 0) { - /* Save ports */ - info->rtp_port[i][dir] = rtp_port; - info->rtp_port[i][!dir] = htons(nated_port); - } else { + nated_port))) { nf_ct_unexpect_related(rtp_exp); nf_ct_unexpect_related(rtcp_exp); return -1; } + /* Save ports */ + info->rtp_port[i][dir] = rtp_port; + info->rtp_port[i][!dir] = htons(nated_port); + /* Success */ pr_debug("nf_nat_h323: expect RTP %pI4:%hu->%pI4:%hu\n", &rtp_exp->tuple.src.u3.ip, @@ -370,15 +370,15 @@ static int nat_h245(struct sk_buff *skb, /* Modify signal */ if (set_h225_addr(skb, protoff, data, dataoff, taddr, &ct->tuplehash[!dir].tuple.dst.u3, - htons(nated_port)) == 0) { - /* Save ports */ - info->sig_port[dir] = port; - info->sig_port[!dir] = htons(nated_port); - } else { + htons(nated_port))) { nf_ct_unexpect_related(exp); return -1; } + /* Save ports */ + info->sig_port[dir] = port; + info->sig_port[!dir] = htons(nated_port); + pr_debug("nf_nat_q931: expect H.245 %pI4:%hu->%pI4:%hu\n", &exp->tuple.src.u3.ip, ntohs(exp->tuple.src.u.tcp.port), @@ -462,24 +462,27 @@ static int nat_q931(struct sk_buff *skb, /* Modify signal */ if (set_h225_addr(skb, protoff, data, 0, &taddr[idx], &ct->tuplehash[!dir].tuple.dst.u3, - htons(nated_port)) == 0) { - /* Save ports */ - info->sig_port[dir] = port; - info->sig_port[!dir] = htons(nated_port); - - /* Fix for Gnomemeeting */ - if (idx > 0 && - get_h225_addr(ct, *data, &taddr[0], &addr, &port) && - (ntohl(addr.ip) & 0xff000000) == 0x7f000000) { - set_h225_addr(skb, protoff, data, 0, &taddr[0], - &ct->tuplehash[!dir].tuple.dst.u3, - info->sig_port[!dir]); - } - } else { + htons(nated_port))) { nf_ct_unexpect_related(exp); return -1; } + /* Save ports */ + info->sig_port[dir] = port; + info->sig_port[!dir] = htons(nated_port); + + /* Fix for Gnomemeeting */ + if (idx > 0 && + get_h225_addr(ct, *data, &taddr[0], &addr, &port) && + (ntohl(addr.ip) & 0xff000000) == 0x7f000000) { + if (set_h225_addr(skb, protoff, data, 0, &taddr[0], + &ct->tuplehash[!dir].tuple.dst.u3, + info->sig_port[!dir])) { + nf_ct_unexpect_related(exp); + return -1; + } + } + /* Success */ pr_debug("nf_nat_ras: expect Q.931 %pI4:%hu->%pI4:%hu\n", &exp->tuple.src.u3.ip, @@ -550,9 +553,9 @@ static int nat_callforwarding(struct sk_ } /* Modify signal */ - if (!set_h225_addr(skb, protoff, data, dataoff, taddr, - &ct->tuplehash[!dir].tuple.dst.u3, - htons(nated_port)) == 0) { + if (set_h225_addr(skb, protoff, data, dataoff, taddr, + &ct->tuplehash[!dir].tuple.dst.u3, + htons(nated_port))) { nf_ct_unexpect_related(exp); return -1; }