From patchwork Sat Jan 5 17:09:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13821 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8461123E2E for ; Sat, 5 Jan 2013 17:10:11 +0000 (UTC) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by fiordland.canonical.com (Postfix) with ESMTP id 171E9A19876 for ; Sat, 5 Jan 2013 17:10:11 +0000 (UTC) Received: by mail-vc0-f174.google.com with SMTP id d16so17489917vcd.5 for ; Sat, 05 Jan 2013 09:10:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-content-scanned:x-cbid:x-gm-message-state; bh=oRA/NSgN1gapeHImCAo8Z7uyJggoPjXXgomg3SS0R+E=; b=KK/dbySYuWhP5ajDgPI5GnTpcc4P+94bUzlEm8/GuTgBd3hbm1ocSolbqMDDCprrak 0mvtQQqmndITUIbGJY7i9DFT1mAbRQJuV+aVRBNUkduil2NwW/sdo2TE+MIg99C+ZM3N ghmUgKnwrWVZaPm+QdjhSjlOK1eieDmnwzEmHkb0T5cXqHaqpY3feOJcEBqEY3FHkvAL wVqUUjvdCR0F7ADbPDB3N2r82gWCATCTIbHmP2XtgD8ddijjYAd1NdT+Rf2WF+GyUurP +szfsb7+HphpKCAKPv+z2T3WtLfXy88ku9oFxOs6wJTu0znvLxUDX4dRsp68btJdRzyK VpXw== X-Received: by 10.52.70.205 with SMTP id o13mr69121362vdu.75.1357405810593; Sat, 05 Jan 2013 09:10:10 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp16341veb; Sat, 5 Jan 2013 09:10:09 -0800 (PST) X-Received: by 10.50.140.34 with SMTP id rd2mr1779337igb.81.1357405806215; Sat, 05 Jan 2013 09:10:06 -0800 (PST) Received: from e34.co.us.ibm.com (e34.co.us.ibm.com. [32.97.110.152]) by mx.google.com with ESMTPS id u4si2610688igi.40.2013.01.05.09.10.05 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 05 Jan 2013 09:10:06 -0800 (PST) Received-SPF: pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.110.152 as permitted sender) client-ip=32.97.110.152; Authentication-Results: mx.google.com; spf=pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.110.152 as permitted sender) smtp.mail=paulmck@linux.vnet.ibm.com Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 5 Jan 2013 10:10:05 -0700 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sat, 5 Jan 2013 10:10:03 -0700 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id C546D1FF0040 for ; Sat, 5 Jan 2013 10:09:52 -0700 (MST) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r05HA2dZ213278 for ; Sat, 5 Jan 2013 10:10:02 -0700 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r05H9vQs017785 for ; Sat, 5 Jan 2013 10:10:02 -0700 Received: from paulmck-ThinkPad-W500 ([9.80.23.97]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r05H9jeM017219; Sat, 5 Jan 2013 10:09:51 -0700 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id 98695E4D82; Sat, 5 Jan 2013 09:09:40 -0800 (PST) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: mingo@elte.hu, laijs@cn.fujitsu.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca, josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, Valdis.Kletnieks@vt.edu, dhowells@redhat.com, edumazet@google.com, darren@dvhart.com, fweisbec@gmail.com, sbw@mit.edu, patches@linaro.org, "Paul E. McKenney" Subject: [PATCH tip/core/rcu 4/6] rcu: Silence compiler array out-of-bounds false positive Date: Sat, 5 Jan 2013 09:09:36 -0800 Message-Id: <1357405778-13903-4-git-send-email-paulmck@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1357405778-13903-1-git-send-email-paulmck@linux.vnet.ibm.com> References: <20130105170920.GA13766@linux.vnet.ibm.com> <1357405778-13903-1-git-send-email-paulmck@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13010517-2876-0000-0000-000003CFAA6B X-Gm-Message-State: ALoCoQlqPl84QbkWK6g/NGEiNdkYFB72B79C0CpMOiWPPZVtySlO1M+3EXKKCjsu8NHr695OVxYA From: "Paul E. McKenney" It turns out that gcc 4.8 warns on array indexes being out of bounds unless it can prove otherwise. It gives this warning on some RCU initialization code. Because this is far from any fastpath, add an explicit check for array bounds and panic if so. This gives the compiler enough information to figure out that the array index is never out of bounds. However, if a similar false positive occurs on a fastpath, it will probably be necessary to tell the compiler to keep its array-index anxieties to itself. ;-) Markus Trippelsdorf Signed-off-by: Paul E. McKenney --- kernel/rcutree.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/kernel/rcutree.c b/kernel/rcutree.c index d145796..e0d9815 100644 --- a/kernel/rcutree.c +++ b/kernel/rcutree.c @@ -2938,6 +2938,10 @@ static void __init rcu_init_one(struct rcu_state *rsp, BUILD_BUG_ON(MAX_RCU_LVLS > ARRAY_SIZE(buf)); /* Fix buf[] init! */ + /* Silence gcc 4.8 warning about array index out of range. */ + if (rcu_num_lvls > RCU_NUM_LVLS) + panic("rcu_init_one: rcu_num_lvls overflow"); + /* Initialize the level-tracking arrays. */ for (i = 0; i < rcu_num_lvls; i++)