lkml.org 
[lkml]   [2011]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] kprobes,x86: disable irq durinr optimized callback
    Date
    hi,

    attached patch is disabling irqs during optimized callback,
    so we dont miss any in-irq kprobes as missed.

    Also I think there's small window where current_kprobe variable
    could be touched in non-safe way, but I was not able to hit
    any issue.

    I'm not sure wether this is a bug or if it was intentional to have
    irqs enabled during the pre_handler callback.

    wbr,
    jirka

    ---
    Disabling irqs during optimized callback, so we dont miss
    any in-irq kprobes as missed.

    Interrupts are also disabled during non-optimized kprobes callbacks.

    Signed-off-by: Jiri Olsa <jolsa@redhat.com>
    ---
    arch/x86/kernel/kprobes.c | 3 +++
    1 files changed, 3 insertions(+), 0 deletions(-)

    diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
    index c969fd9..917cb31 100644
    --- a/arch/x86/kernel/kprobes.c
    +++ b/arch/x86/kernel/kprobes.c
    @@ -1183,11 +1183,13 @@ static void __kprobes optimized_callback(struct optimized_kprobe *op,
    struct pt_regs *regs)
    {
    struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
    + unsigned long flags;

    /* This is possible if op is under delayed unoptimizing */
    if (kprobe_disabled(&op->kp))
    return;

    + local_irq_save(flags);
    preempt_disable();
    if (kprobe_running()) {
    kprobes_inc_nmissed_count(&op->kp);
    @@ -1208,6 +1210,7 @@ static void __kprobes optimized_callback(struct optimized_kprobe *op,
    __this_cpu_write(current_kprobe, NULL);
    }
    preempt_enable_no_resched();
    + local_irq_restore(flags);
    }

    static int __kprobes copy_optimized_instructions(u8 *dest, u8 *src)
    --
    1.7.1


    \
     
     \ /
      Last update: 2011-04-26 15:03    [W:0.020 / U:90.420 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site