Linux Modules
 help / color / mirror / Atom feed
From: Petr Pavlu <petr.pavlu@suse.com>
To: Runyu Xiao <runyu.xiao@seu.edu.cn>
Cc: mcgrof@kernel.org, da.gomez@kernel.org, samitolvanen@google.com,
	linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] module: annotate failed-module stats list traversal
Date: Mon, 22 Jun 2026 08:55:54 +0200	[thread overview]
Message-ID: <31db63df-0a81-45db-97de-67bbe1a1be2a@suse.com> (raw)
In-Reply-To: <20260621091905.3555074-1-runyu.xiao@seu.edu.cn>

On 6/21/26 11:19 AM, Runyu Xiao wrote:
> read_file_mod_stats() dumps dup_failed_modules while holding
> module_mutex, but the loop uses list_for_each_entry_rcu() without
> telling lockdep about that non-RCU protection.
> 
> The same list is already traversed in try_add_failed_module() with
> lockdep_is_held(&module_mutex) as the RCU-list lockdep condition. Use
> the same condition for the debugfs stats dump so CONFIG_PROVE_RCU_LIST
> can see the documented protection.
> 
> This was found by our static analysis tool and then manually reviewed
> against the current tree. The dynamic triage evidence is a
> target-matched CONFIG_PROVE_RCU_LIST warning; the change is limited
> to documenting the existing protection contract.
> 
> This is a lockdep annotation cleanup. It does not change the list
> lifetime or serialization rules.
> 
> Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
> ---
>  kernel/module/stats.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/module/stats.c b/kernel/module/stats.c
> index 3ba0e98b3c91..79c227a72a21 100644
> --- a/kernel/module/stats.c
> +++ b/kernel/module/stats.c
> @@ -382,7 +382,8 @@ static ssize_t read_file_mod_stats(struct file *file, char __user *user_buf,
>  	mutex_lock(&module_mutex);
>  
>  
> -	list_for_each_entry_rcu(mod_fail, &dup_failed_modules, list) {
> +	list_for_each_entry_rcu(mod_fail, &dup_failed_modules, list,
> +				lockdep_is_held(&module_mutex)) {
>  		if (WARN_ON_ONCE(++count_failed >= MAX_FAILED_MOD_PRINT))
>  			goto out_unlock;
>  		len += scnprintf(buf + len, size - len, "%25s\t%15lu\t%25s\n", mod_fail->name,

The same fix was posted previously in:
https://lore.kernel.org/linux-modules/e4za26n3jj3366oqt47hdwfze2rvsyjcujjhjj4jvbtihkleg6@kxasstqoia22/

-- 
Cheers,
Petr

      reply	other threads:[~2026-06-22  6:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-21  9:19 [PATCH] module: annotate failed-module stats list traversal Runyu Xiao
2026-06-22  6:55 ` Petr Pavlu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31db63df-0a81-45db-97de-67bbe1a1be2a@suse.com \
    --to=petr.pavlu@suse.com \
    --cc=da.gomez@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=runyu.xiao@seu.edu.cn \
    --cc=samitolvanen@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox