From patchwork Thu Dec 26 16:39:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 182457 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp1921366ild; Thu, 26 Dec 2019 08:40:11 -0800 (PST) X-Google-Smtp-Source: APXvYqwQ3+1PzqIULQmWFxjVGt4D40cHEa+LUv5R/s8c58levG5j6QWGE82R3CSZtDVfS8jn7Y5/ X-Received: by 2002:a05:6830:2102:: with SMTP id i2mr49433793otc.123.1577378411863; Thu, 26 Dec 2019 08:40:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577378411; cv=none; d=google.com; s=arc-20160816; b=ig5NB7PWWyk13T6066Q7CcdgQhOtomnW++igLfnV1krMi70CWsKa4WIW/tPpZDMUkB u1eWKyBU/sItZDFUFC4JA82BNYGukaL6MqyOv1RkFzOBks4cvQtD0MuiFFhKBYZTdHZj EhSGz6OfKoa5szKN6Dv159EkZ6IfxKJk59Aw62e+l78FQUntuopX78xColL2mvW+z6eN W+MgFuNRjEN+eTxkguMewDA6dOHG8w2PCXXLEHV/z/tU86a3jCjqb+Aw++WRnM6HuFmB C5MgF0YWyGBMwozvBXWAZhF/wE8JSY6da1y1Q7S/p7WZj3ZsEFAUKZAFOC09arm3tgnz rkdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=PyekmO50J5o36jDfvc/4V5WH3gZMWkAmrIUn5MErUxE=; b=g6rbd9rfJcW41ec3zZgPH+ePFMOOHRPLKyf+GNZcwQtJe0Pen5L2NS9lF/bFqBdfn2 /qaL4vZ1V4VPCnowGxijjV1BeRM7OAo6Ccg3GNyj5TcXhsQps+XA5jtaTzuLGEC/oNem WEx3an9fZGjxHJQz3d8PTQ5PzwidOmWea6VfegjKXjDtcfADx/bUywm/KdlGsncSGIQ+ 7laERhqMzTxndIzWw8Svd9+gZ6xPYSHZqrckZlwU8oxK6waZi8zSBT94mnQaw2ZhC5If ywtYTp1nUfH+6S7Ruqdp7T1hmHn2Rhu+RiCpdVbU0A4A4OTqvvEqqavXZ7B3n6oYZtEm OXYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 p22si16219039ota.43.2019.12.26.08.40.11; Thu, 26 Dec 2019 08:40:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726741AbfLZQkK (ORCPT + 9 others); Thu, 26 Dec 2019 11:40:10 -0500 Received: from correo.us.es ([193.147.175.20]:54762 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726684AbfLZQkK (ORCPT ); Thu, 26 Dec 2019 11:40:10 -0500 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id 1BDEBE34EA for ; Thu, 26 Dec 2019 17:40:08 +0100 (CET) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 0C583DA718 for ; Thu, 26 Dec 2019 17:40:08 +0100 (CET) Received: by antivirus1-rhel7.int (Postfix, from userid 99) id 015A6DA713; Thu, 26 Dec 2019 17:40:08 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on antivirus1-rhel7.int X-Spam-Level: X-Spam-Status: No, score=-108.2 required=7.5 tests=ALL_TRUSTED,BAYES_50, SMTPAUTH_US2, URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.1 Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id F0B61DA703; Thu, 26 Dec 2019 17:40:05 +0100 (CET) Received: from 192.168.1.97 (192.168.1.97) by antivirus1-rhel7.int (F-Secure/fsigk_smtp/550/antivirus1-rhel7.int); Thu, 26 Dec 2019 17:40:05 +0100 (CET) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int) Received: from salvia.here (sys.soleta.eu [212.170.55.40]) (Authenticated sender: pneira@us.es) by entrada.int (Postfix) with ESMTPA id D07FB4251481; Thu, 26 Dec 2019 17:40:05 +0100 (CET) X-SMTPAUTHUS: auth mail.us.es From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH 1/4] netfilter: nf_flow_table: fix big-endian integer overflow Date: Thu, 26 Dec 2019 17:39:53 +0100 Message-Id: <20191226163956.672174-2-pablo@netfilter.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191226163956.672174-1-pablo@netfilter.org> References: <20191226163956.672174-1-pablo@netfilter.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann 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 Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_flow_table_offload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c index de7a0d1e15c8..0d72e5ccb47b 100644 --- a/net/netfilter/nf_flow_table_offload.c +++ b/net/netfilter/nf_flow_table_offload.c @@ -88,7 +88,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: