Re: [PATCH v2] parport: do not re-enable interrupts in parport_claim()

From: Greg Kroah-Hartman

Date: Wed Nov 18 2026 - 04:25:22 EST


On Wed, Nov 18, 2026 at 04:48:18PM +0800, Ziheng Wei wrote:
> On Wed, Nov 18, 2026 at 09:11:37AM +0100, Greg Kroah-Hartman wrote:
> > Are you saying that this lock is never held in irq context?
>
> No, it can be taken in hardirq. One path is lp_console_write() ->
> parport_release() -> parport_claim() for a waiting device, as the
> console write callback may run in interrupt context.

Then your change will break things?

> The invariant that matters is that every user disables local
> interrupts before taking waitlist_lock: parport_unregister_device()
> uses spin_lock_irq(), and both wait list paths in parport_claim() run
> under write_lock_irqsave(&port->cad_lock). Plain spin_lock() is
> therefore safe there, even for a hardirq caller.

That feels wrong, don't you think?

> The old spin_unlock_irq() is the problem: it turns interrupts back on
> while cad_lock is still write-held, and for a hardirq caller it does
> so inside the interrupt handler. The "blocked" path in the same
> function already uses plain spin_lock().

Ok, so the larger problem is that we have 2 locks where we should have
just one?

> In your other mail you wrote:
>
> > So, this isn't a real issue given that no one has actually noticed it
> > in 20+ years?
> ...
> > parport devices should not be used by 2 users at once. If you do so,
> > you get to keep the broken pieces :)
>
> Sorry, "two users" was unclear: I meant two parport drivers taking
> turns through the wait list, not simultaneous use, which is what the
> wait list is there for. The race is rare and was found by code
> review, not from a user report. I still think the change is worth
> having, as it is small and fixes the interrupt state, but I will leave
> that decision to you. I am happy to drop it, or to resend with a
> clearer subject and without the stable tag.

If no real user ever hits this (who has parport devices anymore?) then I
would not recomment changing this.

thanks,

greg k-h