From patchwork Fri Jul 28 14:41:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 108891 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp533733obm; Fri, 28 Jul 2017 07:42:13 -0700 (PDT) X-Received: by 10.98.138.204 with SMTP id o73mr7760543pfk.5.1501252933587; Fri, 28 Jul 2017 07:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501252933; cv=none; d=google.com; s=arc-20160816; b=zb0lBhZlAisrftTCiNSZzJloJO3swO7xyvpThvUCioRIuwJ/Na253BK6emOBsXj/GS gPpwLgU7/7Ivx03nQucaetF11MwEHOVhmTI7k6EUsCu3UCNrAP686e1rCoXjBtqof8ap OFPO6b8ozxidoW5WA+n+fBjaxPmh0oFojAHQsMv1WYTSs02qaucdDLwn+dk7I5qnmeLk 8JLihwHeDwDtzWvA3OJDxYXH4OYcUsv2tzo81SZeNHPmuUl7Y0wQBcWL6MRBoYrP3Lkw elBV1/v/PAQnEp1MKL1iCT84ffp12MJgAGvH19O+nMfr6VbiKhJ3zOz6d93hQRPS9nEn LOTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=OUGaQ/yGdvs6a4jgz4MC63dzEnl20egddTHeReiHZXA=; b=yJ/ygMnoLArn+DOCMO9n6eeb+gzSBqUajHLo66Yh5Z3FaokXV0b3q6TOHUcdDonhSK iaoFOf3xzYlmd1Smf34zX7BucHlAPKmb0qSvKrPqn7KBBx+plPm2NuZXtgk9U6BQLprD /mM10yxOVVPnAJDmFUm6u3dt71Ol1r5DRB6YihBF4EOhILh9GviRwxXXJqdRnweZJ9yo WpjCJqcwQJwv15de3Jw7oQt6/u99zvlxx/6JR8fD/CU1iCK39ZICApd3i+SXoQfBxltI 2NNC8+JbuwVde1GQ8f8IiYfihxME7kFC5/ZuFVz2xsw4DqAcDHnM2xU6QJDku4lE//Ah 4EGQ== 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 99si13342331plc.131.2017.07.28.07.42.13; Fri, 28 Jul 2017 07:42:13 -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 S1752323AbdG1OmK (ORCPT + 26 others); Fri, 28 Jul 2017 10:42:10 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:54583 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752293AbdG1OmH (ORCPT ); Fri, 28 Jul 2017 10:42:07 -0400 Received: from wuerfel.lan ([78.43.238.10]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LqlM2-1e5Vb01P50-00eJJx; Fri, 28 Jul 2017 16:42:00 +0200 From: Arnd Bergmann To: "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI Cc: Arnd Bergmann , Eric Dumazet , Neal Cardwell , Soheil Hassas Yeganeh , Yuchung Cheng , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net] tcp: avoid bogus gcc-7 array-bounds warning Date: Fri, 28 Jul 2017 16:41:37 +0200 Message-Id: <20170728144153.2024234-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:p157YBd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ner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When using CONFIG_UBSAN_SANITIZE_ALL, the TCP code produces a false-positive warning: net/ipv4/tcp_output.c: In function 'tcp_connect': net/ipv4/tcp_output.c:2207:40: error: array subscript is below array bounds [-Werror=array-bounds] tp->chrono_stat[tp->chrono_type - 1] += now - tp->chrono_start; ^~ net/ipv4/tcp_output.c:2207:40: error: array subscript is below array bounds [-Werror=array-bounds] tp->chrono_stat[tp->chrono_type - 1] += now - tp->chrono_start; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ I have opened a gcc bug for this, but distros have already shipped compilers with this problem, and it's not clear yet whether there is a way for gcc to avoid the warning. As the problem is related to the bitfield access, this introduces a temporary variable to store the old enum value. I did not notice this warning earlier, since UBSAN is disabled when building with COMPILE_TEST, and that was always turned on in both allmodconfig and randconfig tests. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81601 Signed-off-by: Arnd Bergmann --- net/ipv4/tcp_output.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.9.0 diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 886d874775df..bb901297a369 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2202,9 +2202,10 @@ static bool tcp_small_queue_check(struct sock *sk, const struct sk_buff *skb, static void tcp_chrono_set(struct tcp_sock *tp, const enum tcp_chrono new) { const u32 now = tcp_jiffies32; + enum tcp_chrono old = tp->chrono_type; - if (tp->chrono_type > TCP_CHRONO_UNSPEC) - tp->chrono_stat[tp->chrono_type - 1] += now - tp->chrono_start; + if (old > TCP_CHRONO_UNSPEC) + tp->chrono_stat[old - 1] += now - tp->chrono_start; tp->chrono_start = now; tp->chrono_type = new; }