From: Masami Hiramatsu <mhiramat@kernel.org>
To: Zhou Chengming <zhouchengming1@huawei.com>
Cc: <ananth@linux.vnet.ibm.com>, <anil.s.keshavamurthy@intel.com>,
<davem@davemloft.net>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 2/2] kprobes: initialize probed_mod to NULL
Date: Sat, 28 Oct 2017 17:47:59 +0900 [thread overview]
Message-ID: <20171028174759.f0e161980b69f35d4fe1c74f@kernel.org> (raw)
In-Reply-To: <1509096195-21734-2-git-send-email-zhouchengming1@huawei.com>
On Fri, 27 Oct 2017 17:23:15 +0800
Zhou Chengming <zhouchengming1@huawei.com> wrote:
> When check_kprobe_address_safe() return fail, the probed_mod
> should be set to NULL, because no module refcount held. And we
> initialize probed_mod to NULL in register_kprobe() for the same reason.
>
Ok, it's a kind of hardening code but looks good to me.
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Thank you!
> Signed-off-by: Zhou Chengming <zhouchengming1@huawei.com>
> ---
> kernel/kprobes.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 1eeedac..a04588c 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1488,6 +1488,7 @@ static int check_kprobe_address_safe(struct kprobe *p,
> * its code to prohibit unexpected unloading.
> */
> if (unlikely(!try_module_get(*probed_mod))) {
> + *probed_mod = NULL;
> ret = -ENOENT;
> goto out;
> }
> @@ -1514,7 +1515,7 @@ int register_kprobe(struct kprobe *p)
> {
> int ret;
> struct kprobe *old_p;
> - struct module *probed_mod;
> + struct module *probed_mod = NULL;
> kprobe_opcode_t *addr;
>
> /* Adjust probe address from symbol */
> --
> 1.8.3.1
>
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2017-10-28 8:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-27 9:23 [PATCH v3 1/2] kprobes: avoid the kprobe being re-registered Zhou Chengming
2017-10-27 9:23 ` [PATCH v3 2/2] kprobes: initialize probed_mod to NULL Zhou Chengming
2017-10-28 8:47 ` Masami Hiramatsu [this message]
2017-10-28 8:46 ` [PATCH v3 1/2] kprobes: avoid the kprobe being re-registered 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=20171028174759.f0e161980b69f35d4fe1c74f@kernel.org \
--to=mhiramat@kernel.org \
--cc=ananth@linux.vnet.ibm.com \
--cc=anil.s.keshavamurthy@intel.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=zhouchengming1@huawei.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
Powered by JetHome