public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Wang ShaoBo <bobo.shaobowang@huawei.com>,
	<naveen.n.rao@linux.ibm.com>, <anil.s.keshavamurthy@intel.com>,
	<davem@davemloft.net>, <linux-kernel@vger.kernel.org>,
	<huawei.libin@huawei.com>, <cj.chengjian@huawei.com>
Subject: Re: [PATCH] kretprobe: avoid re-registration of the same kretprobe earlier
Date: Mon, 30 Nov 2020 16:18:50 -0500	[thread overview]
Message-ID: <20201130161850.34bcfc8a@gandalf.local.home> (raw)
In-Reply-To: <20201124115719.11799-1-bobo.shaobowang@huawei.com>


Masami,

Can you review this patch, and also, should this go to -rc and stable?

-- Steve


On Tue, 24 Nov 2020 19:57:19 +0800
Wang ShaoBo <bobo.shaobowang@huawei.com> wrote:

> Our system encountered a re-init error when re-registering same kretprobe,
> where the kretprobe_instance in rp->free_instances is illegally accessed
> after re-init.
> 
> Implementation to avoid re-registration has been introduced for kprobe
> before, but lags for register_kretprobe(). We must check if kprobe has
> been re-registered before re-initializing kretprobe, otherwise it will
> destroy the data struct of kretprobe registered, which can lead to memory
> leak, system crash, also some unexpected behaviors.
> 
> we use check_kprobe_rereg() to check if kprobe has been re-registered
> before calling register_kretprobe(), for giving a warning message and
> terminate registration process.
> 
> Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
> Signed-off-by: Cheng Jian <cj.chengjian@huawei.com>
> ---
>  kernel/kprobes.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 41fdbb7953c6..7f54a70136f3 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -2117,6 +2117,14 @@ int register_kretprobe(struct kretprobe *rp)
>  		}
>  	}
>  
> +	/*
> +	 * Return error if it's being re-registered,
> +	 * also give a warning message to the developer.
> +	 */
> +	ret = check_kprobe_rereg(&rp->kp);
> +	if (WARN_ON(ret))
> +		return ret;
> +
>  	rp->kp.pre_handler = pre_handler_kretprobe;
>  	rp->kp.post_handler = NULL;
>  	rp->kp.fault_handler = NULL;

	

  reply	other threads:[~2020-11-30 21:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24 11:57 [PATCH] kretprobe: avoid re-registration of the same kretprobe earlier Wang ShaoBo
2020-11-30 21:18 ` Steven Rostedt [this message]
2020-12-01 23:32   ` Masami Hiramatsu
2020-12-02  1:23     ` Wangshaobo (bobo)
2020-12-02  1:27       ` Steven Rostedt
2020-12-14 16:36       ` Steven Rostedt
2020-12-15  3:31       ` Masami Hiramatsu
2020-12-15  8:39         ` Wangshaobo (bobo)
2020-12-21 13:31         ` Wangshaobo (bobo)
2020-12-22 11:03           ` Masami Hiramatsu
2021-01-13 22:48             ` Steven Rostedt
2021-01-14  0:25               ` Masami Hiramatsu
2021-01-14  1:06                 ` Wangshaobo (bobo)
2021-01-29  3:37             ` Wangshaobo (bobo)

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=20201130161850.34bcfc8a@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=bobo.shaobowang@huawei.com \
    --cc=cj.chengjian@huawei.com \
    --cc=davem@davemloft.net \
    --cc=huawei.libin@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=naveen.n.rao@linux.ibm.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