Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5844508ybl; Tue, 10 Dec 2019 12:25:51 -0800 (PST) X-Google-Smtp-Source: APXvYqyFbgsMIA2TH2w/qoGWptpiQXM/AX1ifDAQJpGGBG+QrxcHz0jkyqzpLYuFlN6a38PSdpK9 X-Received: by 2002:a9d:1988:: with SMTP id k8mr28060265otk.316.1576009551623; Tue, 10 Dec 2019 12:25:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576009551; cv=none; d=google.com; s=arc-20160816; b=hJdEKb5CryRdLcq98rJgtOdX3ZkymcUW8sEE8ZDs9hRjgsQWAeCjRhQcuBPu7HIRn2 TFqv9MBR/rWUimEW/xc51BILRoo+CBrXeRZiGFqncjhb+b94Y20PQvADgTY4xqplcH25 /Tp3TWD40OuQmFjRCf4mElS32CTcTE0yAIIybtIXAttlzCpMEAMINRClvilSwyCM/IVJ VRAjm9fc6YVULE4bffEP1X4zZSlcAsbrODxBtQ1LBJbDXZht898mK5AROcBMh2i6lxy9 edXY24aZJE7lyAFaZ+Kudbhqvpfp5nQDypZbcRFUkoJAAyTbC1WicZN7fEKqXBqw1IPz Z39w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=2iFlJ0DWe2SO4J0Q0+As7HVevnuaOKOMTgX3oDSXw/k=; b=JWt+ngbhCR6oJmvmDRRF03MaJnlWld+5g3rp6YgZp3ceRwmTcyHWBqxQfU4tydw9JI VE6rm1H097BtxYiQmjk3WPvt0Iv+WyVa9OZVmNGkLmr4WSDZJboXuSSuyCv8XeJnlMTq fY51IjpXlitOulngTMmt60v67yKo2zqgBXvqpCenlGSEcQgZhJc6efuT7UArm7O/XQIK 2cNlro6L/GgkkG5P30czD6VK5jLVpZsoG2YXhh1Nys7UkU6TJsbEPoqexkOAlp0di05O baBBsJcOcN9I7XvbtzlKLFozKC18zslvEvlW4jJb9JHOKBlYbdmKYobb+Rlx7jyk3VB9 g26w== 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 a93si2639378otc.24.2019.12.10.12.25.39; Tue, 10 Dec 2019 12:25:51 -0800 (PST) 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 S1726928AbfLJUZD (ORCPT + 99 others); Tue, 10 Dec 2019 15:25:03 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:34719 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726500AbfLJUZD (ORCPT ); Tue, 10 Dec 2019 15:25:03 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1N2Ujn-1hanVi3ZEN-013uwN; Tue, 10 Dec 2019 21:24:45 +0100 From: Arnd Bergmann To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" Cc: Arnd Bergmann , wenxu , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] netfilter: nf_flow_table: fix big-endian integer overflow Date: Tue, 10 Dec 2019 21:24:28 +0100 Message-Id: <20191210202443.2226043-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1: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BFxP5CaxhL35Q5xW PKQWJ1wuP8P4I3lcTLL/5y6Ex8Schf/ZRkzraf1Cq4LtTuPIrKcMBrT9g6RuqQQb1mC0knUP2 0wumud9eS2tZCkc/hTkg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In some configurations, gcc reports an integer overflow: net/netfilter/nf_flow_table_offload.c: In function 'nf_flow_rule_match': net/netfilter/nf_flow_table_offload.c:80:21: error: unsigned conversion from 'int' to '__be16' {aka 'short unsigned int'} changes value from '327680' to '0' [-Werror=overflow] mask->tcp.flags = TCP_FLAG_RST | TCP_FLAG_FIN; ^~~~~~~~~~~~ From what I can tell, we want the upper 16 bits of these constants, so they need to be shifted in cpu-endian mode. Fixes: c29f74e0df7a ("netfilter: nf_flow_table: hardware offload support") Signed-off-by: Arnd Bergmann --- I'm not sure if this is the correct fix, please check carefully --- net/netfilter/nf_flow_table_offload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c index c54c9a6cc981..24543c45d501 100644 --- a/net/netfilter/nf_flow_table_offload.c +++ b/net/netfilter/nf_flow_table_offload.c @@ -77,7 +77,7 @@ static int nf_flow_rule_match(struct nf_flow_match *match, switch (tuple->l4proto) { case IPPROTO_TCP: key->tcp.flags = 0; - mask->tcp.flags = TCP_FLAG_RST | TCP_FLAG_FIN; + mask->tcp.flags = cpu_to_be16(be32_to_cpu(TCP_FLAG_RST | TCP_FLAG_FIN) >> 16); match->dissector.used_keys |= BIT(FLOW_DISSECTOR_KEY_TCP); break; case IPPROTO_UDP: -- 2.20.0