From patchwork Mon Aug 19 08:00:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 268127 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 431EC2C00B7 for ; Mon, 19 Aug 2013 18:00:41 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750828Ab3HSIA1 (ORCPT ); Mon, 19 Aug 2013 04:00:27 -0400 Received: from s3.sipsolutions.net ([144.76.43.152]:50182 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750734Ab3HSIAZ (ORCPT ); Mon, 19 Aug 2013 04:00:25 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1VBKNu-0004k8-5L; Mon, 19 Aug 2013 10:00:18 +0200 Message-ID: <1376899214.14734.6.camel@jlt4.sipsolutions.net> Subject: Re: 3.11-rc6 genetlink locking fix offends lockdep From: Johannes Berg To: Hugh Dickins Cc: Linus Torvalds , Greg KH , "David S. Miller" , "Otcheretianski, Andrei" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "stable@vger.kernel.org" , Pravin B Shelar , Thomas Graf Date: Mon, 19 Aug 2013 10:00:14 +0200 In-Reply-To: References: X-Mailer: Evolution 3.6.3-1 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org > 3.11-rc6's commit 58ad436fcf49 ("genetlink: fix family dump race") > gives me the lockdep trace below at startup. Hmm. Yes, I see now how this happens, not sure why I didn't run into it. The problem is that genl_family_rcv_msg() is called with the genl_lock held, and then calls netlink_dump_start() with it held, creating a genl_lock->cb_mutex dependency, but obviously the dump continuation is the other way around. We could use the semaphore instead, I believe, but I don't really understand the mutex vs. semaphore well enough to be sure that's correct. johannes --- 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/netlink/genetlink.c b/net/netlink/genetlink.c index f85f8a2..6cfa646 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -792,7 +792,7 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb) bool need_locking = chains_to_skip || fams_to_skip; if (need_locking) - genl_lock(); + down_read(&cb_lock); for (i = chains_to_skip; i < GENL_FAM_TAB_SIZE; i++) { n = 0; @@ -815,7 +815,7 @@ errout: cb->args[1] = n; if (need_locking) - genl_unlock(); + up_read(&cb_lock); return skb->len; }