From patchwork Tue Aug 9 17:02:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 109261 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 7B9B7B6F87 for ; Wed, 10 Aug 2011 03:03:10 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754147Ab1HIRDF (ORCPT ); Tue, 9 Aug 2011 13:03:05 -0400 Received: from service87.mimecast.com ([94.185.240.25]:51173 "HELO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754011Ab1HIRDD (ORCPT ); Tue, 9 Aug 2011 13:03:03 -0400 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 09 Aug 2011 18:03:00 +0100 Received: from localhost.localdomain ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 9 Aug 2011 18:02:55 +0100 From: Mark Rutland To: netdev@vger.kernel.org Cc: Mark Rutland , "David S. Miller" , Eric Dumazet , Gergely Kalman Subject: [PATCH] Fix RCU warning in rt_cache_seq_show Date: Tue, 9 Aug 2011 18:02:40 +0100 Message-Id: <1312909360-2675-1-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.7.0.4 X-OriginalArrivalTime: 09 Aug 2011 17:02:55.0706 (UTC) FILETIME=[2EDB43A0:01CC56B6] X-MC-Unique: 111080918030000801 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Commit f2c31e32 ("net: fix NULL dereferences in check_peer_redir()") added rcu protection to dst neighbour, and updated callsites for dst_{get,set}_neighbour. Unfortunately, it missed rt_cache_seq_show. This produces a warning on v3.1-rc1 (on a preemptible kernel, on an ARM Vexpress A9x4): =================================================== [ INFO: suspicious rcu_dereference_check() usage. ] --------------------------------------------------- include/net/dst.h:91 invoked rcu_dereference_check() without protection! other info that might help us debug this: rcu_scheduler_active = 1, debug_locks = 0 2 locks held by proc01/32159: stack backtrace: [<80014880>] (unwind_backtrace+0x0/0xf8) from [<802e5c78>] (rt_cache_seq_show+0x18c/0x1c4) [<802e5c78>] (rt_cache_seq_show+0x18c/0x1c4) from [<800e0c5c>] (seq_read+0x324/0x4a4) [<800e0c5c>] (seq_read+0x324/0x4a4) from [<8010786c>] (proc_reg_read+0x70/0x94) [<8010786c>] (proc_reg_read+0x70/0x94) from [<800c0ba8>] (vfs_read+0xb0/0x144) [<800c0ba8>] (vfs_read+0xb0/0x144) from [<800c0ea8>] (sys_read+0x40/0x70) [<800c0ea8>] (sys_read+0x40/0x70) from [<8000e0c0>] (ret_fast_syscall+0x0/0x3c) This patch adds calls to rcu_read_{lock,unlock} in rt_cache_seq_show, protecting the dereferenced variable, and clearing the warning. Signed-off-by: Mark Rutland Cc: David S. Miller Cc: Eric Dumazet Cc: Gergely Kalman --- net/ipv4/route.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/net/ipv4/route.c b/net/ipv4/route.c index e3dec1c..6699ef7 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -419,6 +419,7 @@ static int rt_cache_seq_show(struct seq_file *seq, void *v) struct neighbour *n; int len; + rcu_read_lock(); n = dst_get_neighbour(&r->dst); seq_printf(seq, "%s\t%08X\t%08X\t%8X\t%d\t%u\t%d\t" "%08X\t%d\t%u\t%u\t%02X\t%d\t%1d\t%08X%n", @@ -435,6 +436,7 @@ static int rt_cache_seq_show(struct seq_file *seq, void *v) -1, (n && (n->nud_state & NUD_CONNECTED)) ? 1 : 0, r->rt_spec_dst, &len); + rcu_read_unlock(); seq_printf(seq, "%*s\n", 127 - len, ""); }