From: walter harms <wharms@bfs.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 2/2] kprobes: verify jprobe entry point
Date: Thu, 05 Aug 2010 09:41:41 +0000 [thread overview]
Message-ID: <4C5A8755.4010803@bfs.de> (raw)
In-Reply-To: <1280820323-18929-2-git-send-email-namhyung@gmail.com>
Namhyung Kim schrieb:
> verify jprobe's entry point is a function entry point
> using kallsyms' offset value.
>
> Signed-off-by: Namhyung Kim <namhyung@gmail.com>
>
> ---
>
> Here comes 3rd revision of the patch. Thanks to Masami Hiramatus for suggesting
> kallsyms_lookup_size_offset. :-)
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 8f96701..1b0dbe0 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1339,14 +1339,18 @@ int __kprobes register_jprobes(struct jprobe **jps, int num)
> if (num <= 0)
> return -EINVAL;
> for (i = 0; i < num; i++) {
> - unsigned long addr;
> + unsigned long addr, offset;
> jp = jps[i];
> addr = arch_deref_entry_point(jp->entry);
>
> - /* Todo: Verify probepoint is a function entry point */
> - jp->kp.pre_handler = setjmp_pre_handler;
> - jp->kp.break_handler = longjmp_break_handler;
> - ret = register_kprobe(&jp->kp);
> + /* Verify probepoint is a function entry point */
> + if (kallsyms_lookup_size_offset(addr, NULL, &offset) &&
> + offset = 0) {
> + jp->kp.pre_handler = setjmp_pre_handler;
> + jp->kp.break_handler = longjmp_break_handler;
> + ret = register_kprobe(&jp->kp);
> + } else
> + ret = -EINVAL;
>
> if (ret < 0) {
> if (i > 0)
I am a bit converned about this code here:
if (kallsyms_lookup_size_offset(addr, NULL, &offset) && offset = 0)
offset is set inside kallsyms_lookup_size_offset(), right ?
but can you guarantee that the calling sequence is the same on all processors ?
(it is not in case of functions).
perhaps it is more secure (and readable) to do:
ret=kallsyms_lookup_size_offset(addr, NULL, &offset);
if ( ret && offset = 0 )
just my 2 cents,
re,
wh
next prev parent reply other threads:[~2010-08-05 9:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-03 7:25 [PATCH 2/2] kprobes: verify jprobe entry point Namhyung Kim
2010-08-03 11:27 ` Masami Hiramatsu
2010-08-03 13:00 ` Namhyung Kim
2010-08-03 13:42 ` Namhyung Kim
2010-08-04 4:26 ` Masami Hiramatsu
2010-08-04 13:34 ` Namhyung Kim
2010-08-05 9:06 ` Masami Hiramatsu
2010-08-05 9:41 ` walter harms [this message]
2010-08-05 9:47 ` Julia Lawall
2010-08-05 9:59 ` Dan Carpenter
2010-08-05 11:14 ` Håkon Løvdal
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=4C5A8755.4010803@bfs.de \
--to=wharms@bfs.de \
--cc=kernel-janitors@vger.kernel.org \
/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.