From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Ziheng Wei <zihengw03@163.com>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] parport: do not re-enable interrupts in parport_claim()
Date: Wed, 18 Nov 2026 10:25:15 +0100 [thread overview]
Message-ID: <2026111833-smudge-judicial-02bf@gregkh> (raw)
In-Reply-To: <20261118084818.2348842-1-zihengw03@163.com>
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
prev parent reply other threads:[~2026-11-18 9:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 7:58 [PATCH v2] parport: do not re-enable interrupts in parport_claim() Ziheng Wei
2026-11-18 8:09 ` Greg Kroah-Hartman
2026-11-18 8:11 ` Greg Kroah-Hartman
2026-11-18 8:48 ` Ziheng Wei
2026-11-18 9:25 ` Greg Kroah-Hartman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2026111833-smudge-judicial-02bf@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=sudipm.mukherjee@gmail.com \
--cc=zihengw03@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.