Re: [PATCH] protect 'action' in show_interrupts

Andrew Morton (akpm@digeo.com)
Fri, 7 Mar 2003 02:28:29 -0800


Zwane Mwaikambo <zwane@linuxpower.ca> wrote:
>
> This patch protects a critical section in show_interrupts against
> removal of 'action' during traversal of the handlers. All the
> architectures in one swoop.

Thanks for doing this.

> ...
> --- linux-2.5.64/arch/i386/kernel/irq.c 5 Mar 2003 05:08:03 -0000 1.1.1.1
> +++ linux-2.5.64/arch/i386/kernel/irq.c 7 Mar 2003 09:04:43 -0000
> static void register_irq_proc (unsigned int irq);
> @@ -135,6 +135,7 @@
> {
> int i, j;
> struct irqaction * action;
> + unsigned long flags;
>
> seq_printf(p, " ");
> for (j=0; j<NR_CPUS; j++)
> @@ -156,11 +157,17 @@
> kstat_cpu(j).irqs[i]);
> #endif
> seq_printf(p, " %14s", irq_desc[i].handler->typename);
> + spin_lock_irqsave(&irq_desc[i].lock, flags);
> + if (!action)
> + goto unlock;
> + seq_printf(p, " %s", action->name);

Local variable `action' could be pointing at freed memory by now. We need to
reload it inside the lock. Or just hold the lock across the entire loop.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/