lkml.org 
[lkml]   [2011]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/4] MIPS Kprobes: Deny probes on ll/sc instructions
On 11/08/2011 09:05 AM, Maneesh Soni wrote:
>
> From: Maneesh Soni<manesoni@cisco.com>
>
> Deny probes on ll/sc instructions for MIPS kprobes
>
> As ll/sc instruction are for atomic read-modify-write operations, allowing
> probes on top of these insturctions is a bad idea.
>

s/insturctions/instructions/

Not only is it a bad idea, it will probably make them fail 100% of the time.

It is also an equally bad idea to place a probe between any LL and SC
instructions. How do you prevent that?

If you cannot prevent probes between LL and SC, why bother with this at all?

David Daney

> Signed-off-by: Victor Kamensky<kamensky@cisco.com>
> Signed-off-by: Maneesh Soni<manesoni@cisco.com>
> ---
> arch/mips/kernel/kprobes.c | 31 +++++++++++++++++++++++++++++++
> 1 files changed, 31 insertions(+), 0 deletions(-)
>
> diff --git a/arch/mips/kernel/kprobes.c b/arch/mips/kernel/kprobes.c
> index 9fb1876..0ab1a5f 100644
> --- a/arch/mips/kernel/kprobes.c
> +++ b/arch/mips/kernel/kprobes.c
> @@ -113,6 +113,30 @@ insn_ok:
> return 0;
> }
>
> +/*
> + * insn_has_ll_or_sc function checks whether instruction is ll or sc
> + * one; putting breakpoint on top of atomic ll/sc pair is bad idea;
> + * so we need to prevent it and refuse kprobes insertion for such
> + * instructions; cannot do much about breakpoint in the middle of
> + * ll/sc pair; it is upto user to avoid those places
> + */
> +static int __kprobes insn_has_ll_or_sc(union mips_instruction insn)
> +{
> + int ret = 0;
> +
> + switch (insn.i_format.opcode) {
> + case ll_op:
> + case lld_op:
> + case sc_op:
> + case scd_op:
> + ret = 1;
> + break;
> + default:
> + break;
> + }
> + return ret;
> +}
> +
> int __kprobes arch_prepare_kprobe(struct kprobe *p)
> {
> union mips_instruction insn;
> @@ -121,6 +145,13 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
>
> insn = p->addr[0];
>
> + if (insn_has_ll_or_sc(insn)) {
> + pr_notice("Kprobes for ll and sc instructions are not"
> + "supported\n");
> + ret = -EINVAL;
> + goto out;
> + }
> +
> if (insn_has_delayslot(insn)) {
> pr_notice("Kprobes for branch and jump instructions are not"
> "supported\n");



\
 
 \ /
  Last update: 2011-11-08 21:03    [W:0.155 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site