Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH] Input: gscps2 - supply PA-RISC keyboard keymap via device property
Date: Mon, 03 Aug 2026 05:08:04 +0000	[thread overview]
Message-ID: <20260803050805.6702E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <am_9BvmZu9g4RlUM@google.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Use-after-free in shared interrupt handler during device removal.
- [High] Data race and hardware state corruption due to missing lock in `gscps2_flush()`.
--

--- Patch [1]: [PATCH] Input: gscps2 - supply PA-RISC keyboard keymap via device property ---
commit a01a8cad369fa3c00ef5c659a70dd84ac7f1e275
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: gscps2 - supply PA-RISC keyboard keymap via device property

This commit modifies the gscps2 PS/2 port driver to attach a software node
with a linux,keymap property to the serio device. This replaces compile-time
architecture-specific keyboard hacks in the generic atkbd driver. It also
moves the keymap definitions to the serio driver and resolves conflicting
keys via a compile-time config.

> diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c
> index bf9b993f57330..cd1bca57fda33 100644
> --- a/drivers/input/serio/gscps2.c
> +++ b/drivers/input/serio/gscps2.c
[ ... ]
> @@ -434,6 +449,9 @@ static void __exit gscps2_remove(struct parisc_device *dev)
>  {
>  	struct gscps2port *ps2port = dev_get_drvdata(&dev->dev);
>  
> +	if (ps2port->id == GSC_ID_KEYBOARD)
> +		device_remove_software_node(&ps2port->port->dev);
> +
>  	serio_unregister_port(ps2port->port);
>  	free_irq(dev->irq, ps2port);

[Severity: High]
This is a pre-existing issue, but could this sequence in gscps2_remove() lead
to a use-after-free if a shared interrupt fires?

serio_unregister_port() synchronously disconnects the driver and drops the
reference to the port, freeing the serio structure. However, the device
remains in ps2port_list and the shared IRQ is still active since free_irq()
hasn't been called yet.

If another device on the same shared IRQ line triggers an interrupt during
this window, gscps2_interrupt() will iterate over ps2port_list, find this
port, and call serio_interrupt(ps2port->port, ...).

Since ps2port->port was just freed by serio_unregister_port(), will this
dereference freed memory?

Should the device be removed from ps2port_list and its IRQ disabled via
free_irq() before unregistering the serio port?

>  	gscps2_flush(ps2port);

[Severity: High]
This is also a pre-existing issue, but is there a missing lock in
gscps2_flush() that causes a data race?

Looking at gscps2_flush():

static void gscps2_flush(struct gscps2port *ps2port)
{
        while (gscps2_readb_status(ps2port->addr) & GSC_STAT_RBNE)
                gscps2_readb_input(ps2port->addr);
        ps2port->act = ps2port->append = 0;
}

This modifies the shared act and append indices and reads hardware registers
without acquiring ps2port->lock.

When gscps2_open() executes, it calls gscps2_reset() which in turn calls
gscps2_flush(). Since the shared IRQ is requested prior to registration, a
concurrent interrupt triggered by another shared device could cause
gscps2_interrupt() to run.

Because gscps2_interrupt() acquires the lock, reads the same registers, and
modifies append via gscps2_read_data(), will this cause non-serialized
hardware access and buffer state corruption?

>  	list_del(&ps2port->node);
>  	iounmap(ps2port->addr);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/am_9BvmZu9g4RlUM@google.com?part=1

  reply	other threads:[~2026-08-03  5:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03  4:39 [PATCH] Input: gscps2 - supply PA-RISC keyboard keymap via device property Dmitry Torokhov
2026-08-03  5:08 ` sashiko-bot [this message]
2026-08-04 13:59 ` Helge Deller
2026-08-04 18:36   ` Helge Deller
2026-08-06  6:22     ` Dmitry Torokhov
  -- strict thread matches above, loose matches on Subject: below --
2026-07-27  0:37 Dmitry Torokhov
2026-07-27  0:55 ` sashiko-bot

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=20260803050805.6702E1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox