mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
To: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Jim Keniston <jkenisto@us.ibm.com>,
	David Miller <davem@davemloft.net>,
	Rusty Russell <rusty@rustcorp.com.au>,
	LKML <linux-kernel@vger.kernel.org>,
	systemtap-ml <systemtap@sources.redhat.com>
Subject: Re: [PATCH 5/7] kprobes: Remove called_from argument
Date: Wed, 12 Nov 2008 12:22:38 +0530	[thread overview]
Message-ID: <20081112065238.GB3081@in.ibm.com> (raw)
In-Reply-To: <4919F1A9.5070601@redhat.com>

On Tue, Nov 11, 2008 at 03:57:13PM -0500, Masami Hiramatsu wrote:
> Remove called_from argument from kprobes which had been used for preventing
> self-refering of kernel module. However, since we don't keep module's refcount
> after registering kprobe any more, there is no reason to check that.
> 
> This patch also simplifies registering/unregistering functions because we don't
> need to use __builtin_return_address(0) which was passed to called_from.
> 
> Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
> ---
>  kernel/kprobes.c |   70 +++++++++++--------------------------------------------
>  1 file changed, 14 insertions(+), 56 deletions(-)
> 
> Index: 2.6.28-rc4/kernel/kprobes.c
> ===================================================================
> --- 2.6.28-rc4.orig/kernel/kprobes.c
> +++ 2.6.28-rc4/kernel/kprobes.c
> @@ -641,8 +641,7 @@ static kprobe_opcode_t __kprobes *kprobe
>  	return (kprobe_opcode_t *)(((char *)addr) + p->offset);
>  }
> 
> -static int __kprobes __register_kprobe(struct kprobe *p,
> -	unsigned long called_from)
> +int __kprobes register_kprobe(struct kprobe *p)
>  {
>  	int ret = 0;
>  	struct kprobe *old_p;
> @@ -673,13 +672,10 @@ static int __kprobes __register_kprobe(s
>  		 * We must hold a refcount of the probed module while updating
>  		 * its code to prohibit unexpected unloading.
>  		 */
> -		if (calling_mod != probed_mod) {
> -			if (unlikely(!try_module_get(probed_mod))) {
> -				preempt_enable();
> -				return -EINVAL;
> -			}
> -		} else
> -			probed_mod = NULL;
> +		if (unlikely(!try_module_get(probed_mod))) {
> +			preempt_enable();
> +			return -EINVAL;
> +		}

You also need the following to get this to compile, don't you?

Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>

Index: linux-2.6.28-rc4/kernel/kprobes.c
===================================================================
--- linux-2.6.28-rc4.orig/kernel/kprobes.c	2008-11-12 11:13:30.000000000 +0530
+++ linux-2.6.28-rc4/kernel/kprobes.c	2008-11-12 12:18:44.000000000 +0530
@@ -666,8 +666,6 @@
 	 */
 	probed_mod = __module_text_address((unsigned long) p->addr);
 	if (probed_mod) {
-		struct module *calling_mod;
-		calling_mod = __module_text_address(called_from);
 		/*
 		 * We must hold a refcount of the probed module while updating
 		 * its code to prohibit unexpected unloading.

  reply	other threads:[~2008-11-12  6:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-11 20:57 Masami Hiramatsu
2008-11-12  6:52 ` Ananth N Mavinakayanahalli [this message]
2008-11-12 15:36   ` Masami Hiramatsu
2008-11-12 15:58 ` Ananth N Mavinakayanahalli

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=20081112065238.GB3081@in.ibm.com \
    --to=ananth@in.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=jkenisto@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=systemtap@sources.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 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®