mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Dennis1.Chen@amd.com,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH 3/7] module: take rcu_read_lock_sched for find_module
Date: Thu, 15 Mar 2012 09:29:04 -0700	[thread overview]
Message-ID: <1331828944.4874.17.camel@edumazet-glaptop> (raw)
In-Reply-To: <1331822941-19938-3-git-send-email-xiyou.wangcong@gmail.com>

On Thu, 2012-03-15 at 22:48 +0800, Cong Wang wrote:
> Similar to find_symbol(), find_module() also iterates module list,
> should use list_for_each_entry_rcu() too, thus its callers should
> hold rcu_read_lock_sched before calling it.
> 
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> ---
>  kernel/module.c |   42 +++++++++++++++++++++++-------------------
>  1 files changed, 23 insertions(+), 19 deletions(-)
> 
> diff --git a/kernel/module.c b/kernel/module.c
> index b31b23f..f210d74 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -413,7 +413,7 @@ struct module *find_module(const char *name)
>  {
>  	struct module *mod;
>  
> -	list_for_each_entry(mod, &modules, list) {
> +	list_for_each_entry_rcu(mod, &modules, list) {
>  		if (strcmp(mod->name, name) == 0)
>  			return mod;
>  	}
> @@ -778,14 +778,16 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
>  		return -EFAULT;
>  	name[MODULE_NAME_LEN-1] = '\0';
>  
> -	if (mutex_lock_interruptible(&module_mutex) != 0)
> -		return -EINTR;
> -
> +	rcu_read_lock_sched();
>  	mod = find_module(name);
>  	if (!mod) {
> -		ret = -ENOENT;
> -		goto out;
> +		rcu_read_unlock_sched();
> +		return -ENOENT;
>  	}
> +	rcu_read_unlock_sched();
> +

Thats a bug.

> +	if (mutex_lock_interruptible(&module_mutex) != 0)
> +		return -EINTR;

mod might already had disappear.

>  
>  	if (!list_empty(&mod->source_list)) {
>  		/* Other modules depend on us: get rid of them first. */



  reply	other threads:[~2012-03-15 16:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-15 14:48 [V3 PATCH 1/7] module: replace preempt_disable with rcu_read_lock_sched Cong Wang
2012-03-15 14:48 ` [PATCH 2/7] module: take rcu_read_lock_sched for find_symbol Cong Wang
2012-03-15 14:48 ` [PATCH 3/7] module: take rcu_read_lock_sched for find_module Cong Wang
2012-03-15 16:29   ` Eric Dumazet [this message]
2012-03-15 14:48 ` [PATCH 4/7] module: take rcu_read_lock_sched in module_kallsyms_on_each_symbol() Cong Wang
2012-03-15 14:48 ` [PATCH 5/7] module: take rcu_read_lock_sched() for /proc read Cong Wang
2012-03-15 16:18   ` Eric Dumazet
2012-03-15 14:49 ` [PATCH 6/7] module: add two missing synchronize_sched() Cong Wang
2012-03-15 16:26   ` Eric Dumazet
2012-03-15 14:49 ` [PATCH 7/7] module: avoid exporting module_mutex Cong Wang

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=1331828944.4874.17.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=Dennis1.Chen@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=rusty@rustcorp.com.au \
    --cc=xiyou.wangcong@gmail.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

all inboxes | Powered by JetHome®