From patchwork Thu Apr 10 21:30:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 338287 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 93B74140083 for ; Fri, 11 Apr 2014 07:30:56 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759189AbaDJVai (ORCPT ); Thu, 10 Apr 2014 17:30:38 -0400 Received: from mail-ie0-f179.google.com ([209.85.223.179]:44209 "EHLO mail-ie0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935786AbaDJVad (ORCPT ); Thu, 10 Apr 2014 17:30:33 -0400 Received: by mail-ie0-f179.google.com with SMTP id lx4so4573846iec.38 for ; Thu, 10 Apr 2014 14:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=3JCIDpIuAKZHz3c7rHPJ/rPjGHNmWGug1h7d7e/pQGM=; b=JNZqASzJHxENxxecZGCJrRQggSWIvqg8Z2RwyW8QVdFU+GmXPzNgVQFEYfnPB0smbI JfiGU2x0StdAoin+ategorDQApAzz7xk4gkCwPB+1n0bPifZpw8e7smdYr/JGkXi+vmL shpfd0hvyS6zkkdRBvLRfQA5O+VfdwMy8Qi8h+VmZUC9HYxIUBXEE+mka33poKDRASot fJ/64wdHLnxedaT5roI4vSuVBWZqWrvAnhWDzN7+UvaM7dSV6T3OMAagEDVagazgrIdf l5zFJuqAr9tMu2/SPIbpoa3fXJBUhrx7Q3ATZhfOH3Skjiq6r4/1Pabv/8YBwZd682p+ 7z5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:from:cc:date:message-id:user-agent :mime-version:content-type:content-transfer-encoding; bh=3JCIDpIuAKZHz3c7rHPJ/rPjGHNmWGug1h7d7e/pQGM=; b=Db5xdClzom8Tl6tbhWFYCbVrqnZpmUxO6QPyoX6/5HRbFUdv9RkYhmmK6cVg2Gg9Gt /YHiHZTcS5Vj+faaf0uMrQLq649cM5e0yXeuRUKl6xn1Cz0UHKux0PEllB5LgcEuPzvG +ShjbSalKyHtuv9HlaM/llrTl6mFGCPZRo1kSAlHQkj/RVOILf3GUQnBqdhwxmHchgS+ 6BWEPUQTwGIPwPmbRAxVVJFhgmxkZGgT8ZJv0Nv7vIZ+smpeyhe7Vg+A3/B2Y9R6RBav mee/u8TeTH+qMqwhmb658lVJ2LpzQ64gvIs+TpniOFGKIGQKMbWNpCdYgbAZtFXq5k2j ZZiQ== X-Gm-Message-State: ALoCoQkLT6wMNR2JeXiXNa6KWRGOn1PT2iy2Zt1YzFOhqc5X1oIbUQdvaepHLrbEO9/BR+C0m1HyCdn59zdMjZMb4TSn/zf64P5U8XIEeWAIvBbsjvzJ8i3OvZtzu2yR49+5PZcsj+Ny+dlMTvwydodu0Sqi/UI1CrURgW42sthhJgTt73XkpxvrJsZIjqtqo/5tVM6rAU+WL2Xf7r/nCjktyTZWaaiOZA== X-Received: by 10.50.102.33 with SMTP id fl1mr13901946igb.22.1397165432803; Thu, 10 Apr 2014 14:30:32 -0700 (PDT) Received: from localhost ([172.16.50.223]) by mx.google.com with ESMTPSA id kb5sm439227igb.1.2014.04.10.14.30.31 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 10 Apr 2014 14:30:32 -0700 (PDT) Subject: [PATCH] tcp: fix compiler array bounds warning on selective_acks[] To: "David S. Miller" From: Bjorn Helgaas Cc: Florian Fainelli , Hideaki YOSHIFUJI , netdev@vger.kernel.org, James Morris , linux-kernel@vger.kernel.org, David Laight , Alexey Kuznetsov , Patrick McHardy Date: Thu, 10 Apr 2014 15:30:29 -0600 Message-ID: <20140410213029.24916.93892.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org With -Werror=array-bounds, gcc v4.8.x warns that in tcp_sack_remove(), a selective_acks[] "array subscript is above array bounds". I don't understand how gcc figures this out, or why we don't see similar problems many other places, but this is the only fix I can figure out. Signed-off-by: Bjorn Helgaas --- net/ipv4/tcp_input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 65cf90e063d5..65133b108236 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4047,7 +4047,8 @@ static void tcp_sack_remove(struct tcp_sock *tp) /* Zap this SACK, by moving forward any other SACKS. */ for (i = this_sack+1; i < num_sacks; i++) - tp->selective_acks[i-1] = tp->selective_acks[i]; + if (i < ARRAY_SIZE(tp->selective_acks)) + tp->selective_acks[i-1] = tp->selective_acks[i]; num_sacks--; continue; }