From: "Jon Medhurst (Tixy)" <tixy@linaro.org>
To: Wang Nan <wangnan0@huawei.com>
Cc: masami.hiramatsu.pt@hitachi.com, linux@arm.linux.org.uk,
will.deacon@arm.com, dave.long@linaro.org,
taras.kondratiuk@linaro.org, ben.dooks@codethink.co.uk,
cl@linux.com, rabin@rab.in, davem@davemloft.net,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, lizefan@huawei.com
Subject: Re: [PATCH 4/4] ARM: kprobes: disallow probing stack consuming instructions
Date: Tue, 28 Oct 2014 12:00:05 +0000 [thread overview]
Message-ID: <1414497605.1433.3.camel@linaro.org> (raw)
In-Reply-To: <1414219373-20070-5-git-send-email-wangnan0@huawei.com>
On Sat, 2014-10-25 at 14:42 +0800, Wang Nan wrote:
> This patch prohibit probing instructions for which the stack
> requirement are unable to be determined statically. Some test cases
> are found not work again after the modification, this patch also
> removes them.
>
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
[...]
> diff --git a/arch/arm/kernel/kprobes.c b/arch/arm/kernel/kprobes.c
> index 618531d..59f5e64 100644
> --- a/arch/arm/kernel/kprobes.c
> +++ b/arch/arm/kernel/kprobes.c
> @@ -124,6 +124,14 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
> break;
> }
>
> + /*
> + * Unable to instrument insn like 'str r0, [sp, +/-r1]'.
> + * __und_svc protects 64 bytes stack, so instrumenting insn
> + * likes 'str r0, [sp, #-68]' should be prohibited.
> + */
> + if ((p->ainsn.stack_space < 0) || (p->ainsn.stack_space > 64))
Rather than using the hard coded value 64 it would be safest to create a
#define for the value (in arch/arm/include/asm/kprobes.h) and use that
define in __und_svc too.
Actually, there is already a define there for MAX_STACK_SIZE which is
used as the size of the stack for jprobes and the amount copied by
setjmp_pre_handler and longjmp_break_handler, which looks like it has
the same purpose as we want i.e. allowing space for probed instructions
to push things onto the stack. So we should probably use that define in
this patch and update __und_svc too.
Also, jprobe_return has this comment
* We allocate some slack between the original SP and start of
* our fabricated regs. To be precise we want to have worst case
* covered which is STMFD with all 16 regs so we allocate 2 *
* sizeof(struct_pt_regs)).
*
* This is to prevent any simulated instruction from writing
* over the regs when they are accessing the stack.
which looking at the code should probably more accurately specified as
sizeof(struct_pt_regs)+MAX_STACK_SIZE rather than
2*sizeof(struct_pt_regs)
I've not looked at the jprobes specific code before, so it would be good
to have someone else's option on what I save above about how
MAX_STACK_SIZE is and should be used.
--
Tixy
prev parent reply other threads:[~2014-10-28 12:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-25 6:42 [PATCH 0/4] ARM: kprobes: introduces instruction checker Wang Nan
2014-10-25 6:42 ` [PATCH 1/4] ARM: kprobes: seprates load and store actions Wang Nan
2014-10-25 6:42 ` [PATCH 2/4] ARM: kprobes: introduces checker Wang Nan
2014-10-25 6:42 ` [PATCH 3/4] ARM: kprobes: collects stack consumption for store instructions Wang Nan
2014-10-28 16:46 ` Jon Medhurst (Tixy)
2014-10-25 6:42 ` [PATCH 4/4] ARM: kprobes: disallow probing stack consuming instructions Wang Nan
2014-10-28 12:00 ` Jon Medhurst (Tixy) [this message]
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=1414497605.1433.3.camel@linaro.org \
--to=tixy@linaro.org \
--cc=ben.dooks@codethink.co.uk \
--cc=cl@linux.com \
--cc=dave.long@linaro.org \
--cc=davem@davemloft.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=lizefan@huawei.com \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=rabin@rab.in \
--cc=taras.kondratiuk@linaro.org \
--cc=wangnan0@huawei.com \
--cc=will.deacon@arm.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