All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: ananth@in.ibm.com
Cc: Andrew Morton <akpm@linux-foundation.org>,
	David Miller <davem@davemloft.net>,
	mhiramat@redhat.com,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kprobes: disable preempt for module_text_address()
Date: Wed, 05 Nov 2008 08:53:41 +0800	[thread overview]
Message-ID: <4910EE95.9000802@cn.fujitsu.com> (raw)
In-Reply-To: <20081104142824.GA24326@in.ibm.com>

Ananth N Mavinakayanahalli wrote:
> On Tue, Nov 04, 2008 at 01:56:21PM +0800, Lai Jiangshan wrote:
>> __register_kprobe() may be preempted after module_text_address()
>> but before try_module_get(), and in this interval the module may be
>> unloaded and try_module_get(probed_mod) will access to invalid address.
>> this patch uses preempt_disable() to protect it.
> 
> Looking at other users of try_module_get, I don't see this as a usage
> model being followed elsewhere. Also, in case such a preemption does
> happen, module_is_live() will fail and we should still be ok.

when preemption happen, and mod is freed, module_is_live() will access to
invalid address. So it's NOT OK.

Other users of try_module_get() are correct. most are like this:

void func(XXX, XXXX)
{
	try_module_get(XXX->owner)
}

Because we have had a reference to the module before calling try_module_get().
this means the module is still in the kernel when try_module_get() called.
so we do not need any protection for using try_module_get().
<in other word, caller of func() has made sure the module will not be unloaded>

In this function __register_kprobe(), probed_mod is the return value of
module_text_address(), probed_mod will go in any time before try_module_get().

> 
> I don't see a reason for this patch unless there is a clear failure case
> (register_kprobe failing 'cos of a module unload is perfectly ok).
> 
> Ananth
> 





  reply	other threads:[~2008-11-05  0:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-04  5:56 [PATCH] kprobes: disable preempt for module_text_address() Lai Jiangshan
2008-11-04 14:28 ` Ananth N Mavinakayanahalli
2008-11-05  0:53   ` Lai Jiangshan [this message]
2008-11-05  1:27 ` Masami Hiramatsu
2008-11-05  1:47   ` Lai Jiangshan
2008-11-05 19:30     ` Hiroshi Shimamoto
2008-11-05 21:40     ` Masami Hiramatsu
2008-11-05 22:46       ` Hiroshi Shimamoto
2008-11-05 23:07         ` Masami Hiramatsu
2008-11-06  0:06           ` [PATCH] kprobes: bugfix: try_module_get even if calling_mod is NULL Masami Hiramatsu
2008-11-07  1:00             ` Andrew Morton
2008-11-07  2:28               ` Masami Hiramatsu
2008-11-07  2:54                 ` Andrew Morton
2008-11-07  4:46                   ` Ananth N Mavinakayanahalli
2008-11-06  1:06       ` [PATCH] kprobes: disable preempt for module_text_address() Lai Jiangshan
2008-11-06 15:37         ` [PATCH] kprobes: disable preempt for module_text_address() and kernel_text_address() Masami Hiramatsu
2008-11-07  0:32           ` Lai Jiangshan

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=4910EE95.9000802@cn.fujitsu.com \
    --to=laijs@cn.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=ananth@in.ibm.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.