Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp576772ybl; Thu, 23 Jan 2020 04:11:47 -0800 (PST) X-Google-Smtp-Source: APXvYqzK4vbzC4OfIN2GG6227jVXPZXXIbflwZzK2FUTILW/ZE1GcITYyaF5vue4haDkwAUU/XLj X-Received: by 2002:a05:6830:1116:: with SMTP id w22mr11140839otq.63.1579781507100; Thu, 23 Jan 2020 04:11:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579781507; cv=none; d=google.com; s=arc-20160816; b=Csa9CAj4KMH9QLakADVauDnHLMfQBqbzQTLbeCnlUUJO4JMBATo3VNCoE13uCNZxDb FVq1QsJplzOrvOc7ALM4WPaai8F+l3pvHl16iuwjkp0gmIK4uzk+irZSm6kNhIUz01LA p3bzMVE4sODOlMDHXnKmI6GjfZGPal6VbdgWtzfLEPnn1Ba0uvt0cDkYaA5N32XyFfLn xrO/RQTAmEpKgpFOyzTrVJn6pkoDYrCRGYzG/UyEAXR+ycX9K0ZV37V+LCX44Wl12/Zm cyVjVi+J/lRO+4GbJ8kKc4UL/eV3TJ974dR+XX+jU4ersMeXT0vhoRgOvWyNVYPdcZ2E h28w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3igDixFrwMnD2iIBY4+iBmqcxWt4jABdqdS3KBPKDdY=; b=mKgiD+b+bFslA3qpEjF42OARto0Kt/rtCn8hJgJK3mSdw9AaiSAPE0XFd+2dk6UuKr 5ksPdtm0eX8FZasJMM9GSW4iOloAOmOv99XRZFciTAv+5ONMTOWnEzd6Wjgv4r1e3ur5 9WYGypD/am9VtEZ7kvGqCu0oYGMUhOPEo55flOGBScttVWuiWVmAGEyiaIQh4UD5aD5c Dw5ELdj8D0YgGLLZGf0RORYzXF1VOfu5VE4EA1M/Spn9qrrWyA1xor5xNV3H3kWnTnEu 978DAXj2cCtp65R+4vBxl2uyv/RMtXYHJI31AAgxAju7la0bZl30h+Fq3Zd2M7bZeGq9 Akig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=W4eKy3R8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l10si1012848otr.159.2020.01.23.04.11.35; Thu, 23 Jan 2020 04:11:47 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=W4eKy3R8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727893AbgAWMKS (ORCPT + 99 others); Thu, 23 Jan 2020 07:10:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:59548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726170AbgAWMKS (ORCPT ); Thu, 23 Jan 2020 07:10:18 -0500 Received: from linux-8ccs (x2f7fea8.dyn.telefonica.de [2.247.254.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 368AE2253D; Thu, 23 Jan 2020 12:10:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579781417; bh=xVC+of4wwHUmBPk3J4W40b+AoZu4hwXIqW9ignswEJM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=W4eKy3R8Ayy+tpLYSr62z7a1B4h4BFSIyBoED+15X/BvAa8a3ydZvATj73fi9Hpxj qd7W6qYOq1/6VmSHRnQvmcLYLykfIfdFgBFaYUrSpYGtjk1bItgtB8LfdU/HvgBf/+ 6jZidqSQ2dhAoyNEQG8i7kFw4MW+hxqJ1TbEA6NE= Date: Thu, 23 Jan 2020 13:10:10 +0100 From: Jessica Yu To: Amol Grover Cc: linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Joel Fernandes , Madhuparna Bhowmik , "Paul E . McKenney" Subject: Re: [PATCH] kernel: module: Pass lockdep expression to RCU lists Message-ID: <20200123121010.GA9011@linux-8ccs> References: <20200121124745.14864-1-frextrite@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200121124745.14864-1-frextrite@gmail.com> X-OS: Linux linux-8ccs 4.12.14-lp150.12.61-default x86_64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ Amol Grover [21/01/20 18:17 +0530]: >modules is traversed using list_for_each_entry_rcu outside an >RCU read-side critical section but under the protection >of module_mutex or with preemption disabled. > >Hence, add corresponding lockdep expression to silence false-positive >lockdep warnings, and harden RCU lists. > >list_for_each_entry_rcu when traversed inside a preempt disabled >section, doesn't need an explicit lockdep expression since it is >implicitly checked for. > >Add macro for the corresponding lockdep expression. > >Signed-off-by: Amol Grover Hi Amol! Masami already submitted a patch for this, it's been in linux-next for a while. See commit bf08949cc8b9 ("modules: lockdep: Suppress suspicious RCU usage warning"). Thanks! Jessica >--- > kernel/module.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > >diff --git a/kernel/module.c b/kernel/module.c >index b56f3224b161..2425f58159dd 100644 >--- a/kernel/module.c >+++ b/kernel/module.c >@@ -84,6 +84,8 @@ > * 3) module_addr_min/module_addr_max. > * (delete and add uses RCU list operations). */ > DEFINE_MUTEX(module_mutex); >+#define module_mutex_held() \ >+ lockdep_is_held(&module_mutex) > EXPORT_SYMBOL_GPL(module_mutex); > static LIST_HEAD(modules); > >@@ -214,7 +216,7 @@ static struct module *mod_find(unsigned long addr) > { > struct module *mod; > >- list_for_each_entry_rcu(mod, &modules, list) { >+ list_for_each_entry_rcu(mod, &modules, list, module_mutex_held()) { > if (within_module(addr, mod)) > return mod; > } >@@ -448,7 +450,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr, > if (each_symbol_in_section(arr, ARRAY_SIZE(arr), NULL, fn, data)) > return true; > >- list_for_each_entry_rcu(mod, &modules, list) { >+ list_for_each_entry_rcu(mod, &modules, list, module_mutex_held()) { > struct symsearch arr[] = { > { mod->syms, mod->syms + mod->num_syms, mod->crcs, > NOT_GPL_ONLY, false }, >@@ -616,7 +618,7 @@ static struct module *find_module_all(const char *name, size_t len, > > module_assert_mutex_or_preempt(); > >- list_for_each_entry_rcu(mod, &modules, list) { >+ list_for_each_entry_rcu(mod, &modules, list, module_mutex_held()) { > if (!even_unformed && mod->state == MODULE_STATE_UNFORMED) > continue; > if (strlen(mod->name) == len && !memcmp(mod->name, name, len)) >@@ -2040,7 +2042,7 @@ void set_all_modules_text_rw(void) > return; > > mutex_lock(&module_mutex); >- list_for_each_entry_rcu(mod, &modules, list) { >+ list_for_each_entry_rcu(mod, &modules, list, module_mutex_held()) { > if (mod->state == MODULE_STATE_UNFORMED) > continue; > >@@ -2059,7 +2061,7 @@ void set_all_modules_text_ro(void) > return; > > mutex_lock(&module_mutex); >- list_for_each_entry_rcu(mod, &modules, list) { >+ list_for_each_entry_rcu(mod, &modules, list, module_mutex_held()) { > /* > * Ignore going modules since it's possible that ro > * protection has already been disabled, otherwise we'll >-- >2.24.1 >