Re: [PATCH]kprobes fix bug when probed on task and isr functions

Andrew Morton
2005-09-01T21:07:21Z

Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com> wrote:
>
> This patch fixes a race condition where in system used to hang
> or sometime crash within minutes when kprobes are inserted on
> ISR routine and a task routine.

It's desirable that the patch descriptions tell us _how_ a bug was fixed,
as well as what the bug was. It means that people don't have to ask
questions like:

> void __kprobes lock_kprobes(void)
> {
> + unsigned long flags = 0;
> +
> + local_irq_save(flags);
> spin_lock(&kprobe_lock);
> kprobe_cpu = smp_processor_id();
> + local_irq_restore(flags);
> }

what is this change trying to do? If a lock is taken from both process and
irq contexts then local IRQs must be disabled for the entire period when the
lock is held, not just for a little blip like this. If IRQ-context code is
running this function then the code is deadlockable.

Now, probably there's deep magic happening here and I'm wrong. If so then
please explain the code's magic via a comment patch so the question doesn't
arise again, thanks.