All of lore.kernel.org
 help / color / mirror / Atom feed
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 09:09:35 +0100	[thread overview]
Message-ID: <2026111830-doorstep-aloha-5faf@gregkh> (raw)
In-Reply-To: <20261118075816.2323688-1-zihengw03@163.com>

On Wed, Nov 18, 2026 at 03:58:16PM +0800, Ziheng Wei wrote:
> When the claiming device was on the wait list, parport_claim() takes
> it off the list with spin_lock_irq()/spin_unlock_irq() while it holds
> cad_lock with interrupts disabled:
> 
>   parport_claim()
>     |
>     | write_lock_irqsave(&port->cad_lock)     <- IRQs off, cad_lock held
>     | spin_lock_irq(&port->waitlist_lock)
>     | spin_unlock_irq(&port->waitlist_lock)   <- IRQs on too early
>     |
>     +---- port interrupt on this CPU ----+
>     |                                    |
>     |                                    v
>     |                        parport_irq_handler()
>     |                          read_lock(&port->cad_lock)
>     |                          spins forever: cad_lock is held
>     |                          by the code it interrupted
>     |
>     | write_unlock_irqrestore(&port->cad_lock)  <- never reached
> 
> Interrupts are already disabled here, so use spin_lock()/spin_unlock(),
> like the "blocked" path in the same function.
> 
> Found by LLM-assisted static analysis.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

So, this isn't a real issue given that no one has actually noticed it in
20+ years?

> Cc: stable@vger.kernel.org
> Signed-off-by: Ziheng Wei <zihengw03@163.com>
> ---
> 
> Notes:
>     v2: shorter changelog; drop the kernel test robot tags.
>     
>     The bug was found by the static analysis above.  The kernel test robot
>     had sent a smatch warning for the same code to oe-kbuild only, which I
>     found afterwards and credited in v1:
>     https://lore.kernel.org/r/202608091622.jlJn0jOj-lkp@intel.com/
>     
>     Tested in QEMU (parport_pc) with two ppdev users, one waiting in
>     PPCLAIM while the other releases the port: lockdep warns without this
>     patch and is quiet with it.  I have no parallel port hardware.

Then maybe this isn't a real issue?

>     On real hardware this needs two users of the same port and a port
>     interrupt within a few microseconds of the hand-over, so it is
>     unlikely to be hit; lockdep reports it whenever the path runs.

parport devices should not be used by 2 users at once.  If you do so,
you get to keep the broken pieces :)

thanks,

greg k-h

  reply	other threads:[~2026-11-18  8:09 UTC|newest]

Thread overview: 4+ 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 [this message]
2026-11-18  8:11 ` Greg Kroah-Hartman
2026-11-18  8:48   ` Ziheng Wei

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=2026111830-doorstep-aloha-5faf@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.