mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com,
	davem@davemloft.net, corbet@lwn.net, ananth@in.ibm.com,
	akpm@linux-foundation.org, randy.dunlap@oracle.com,
	mathieu.desnoyers@polymtl.ca, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] samples/kretprobes: Fix return value if register_kretprobe() failed
Date: Mon, 25 Oct 2021 15:15:17 +0900	[thread overview]
Message-ID: <20211025151517.f295f7804993e55997f0258f@kernel.org> (raw)
In-Reply-To: <1635132660-5038-2-git-send-email-yangtiezhu@loongson.cn>

On Mon, 25 Oct 2021 11:30:57 +0800
Tiezhu Yang <yangtiezhu@loongson.cn> wrote:

> Use the actual return value instead of always -1 if register_kretprobe()
> failed.
> 
> E.g. without this patch:
> 
>  # insmod samples/kprobes/kretprobe_example.ko func=no_such_func
>  insmod: ERROR: could not insert module samples/kprobes/kretprobe_example.ko: Operation not permitted
> 
> With this patch:
> 
>  # insmod samples/kprobes/kretprobe_example.ko func=no_such_func
>  insmod: ERROR: could not insert module samples/kprobes/kretprobe_example.ko: Unknown symbol in module
> 
> Fixes: 804defea1c02 ("Kprobes: move kprobe examples to samples/")
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>

This looks good to me.

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Thanks!

> ---
>  samples/kprobes/kretprobe_example.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/samples/kprobes/kretprobe_example.c b/samples/kprobes/kretprobe_example.c
> index 5dc1bf3..228321e 100644
> --- a/samples/kprobes/kretprobe_example.c
> +++ b/samples/kprobes/kretprobe_example.c
> @@ -86,7 +86,7 @@ static int __init kretprobe_init(void)
>  	ret = register_kretprobe(&my_kretprobe);
>  	if (ret < 0) {
>  		pr_err("register_kretprobe failed, returned %d\n", ret);
> -		return -1;
> +		return ret;
>  	}
>  	pr_info("Planted return probe at %s: %p\n",
>  			my_kretprobe.kp.symbol_name, my_kretprobe.kp.addr);
> -- 
> 2.1.0
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2021-10-25  6:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25  3:30 [PATCH 0/4] Do some changes about kprobe Tiezhu Yang
2021-10-25  3:30 ` [PATCH 1/4] samples/kretprobes: Fix return value if register_kretprobe() failed Tiezhu Yang
2021-10-25  6:15   ` Masami Hiramatsu [this message]
2021-10-25  3:30 ` [PATCH 2/4] docs, kprobes: Remove invalid URL and add new reference Tiezhu Yang
2021-10-25  6:29   ` Masami Hiramatsu
2021-10-25  3:30 ` [PATCH 3/4] test_kprobes: Move it from kernel/ to lib/ Tiezhu Yang
2021-10-25  6:33   ` Masami Hiramatsu
2021-10-25  3:31 ` [PATCH 4/4] MAINTAINERS: Add git tree and missing files for KPROBES Tiezhu Yang
2021-10-25  6:38   ` Masami Hiramatsu
2021-10-25  8:31     ` Tiezhu Yang
2021-10-25 14:48       ` Steven Rostedt
2021-10-25  6:14 ` [PATCH 0/4] Do some changes about kprobe Masami Hiramatsu

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=20211025151517.f295f7804993e55997f0258f@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=ananth@in.ibm.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=randy.dunlap@oracle.com \
    --cc=yangtiezhu@loongson.cn \
    /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®