All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pei Xiao" <xiaopei01@kylinos.cn>
Cc: cassel@kernel.org, linux-ide@vger.kernel.org, dlemoal@kernel.org
Subject: Re: [PATCH v2 2/2] ata: pata_parport: unregister devices on protocol unregister
Date: Tue, 08 Sep 2026 12:08:55 +0000	[thread overview]
Message-ID: <20260908120855.9F34F1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <cec58ea83362df88f516ba7a5b895cf07edd7728.1788867690.git.xiaopei01@kylinos.cn>

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

Pre-existing issues:
- [High] pata_parport_attach fails for all parports except port 0
--

commit b043c5b13721ce815e34642853318549a000ffd3
Author: Pei Xiao <xiaopei01@kylinos.cn>

ata: pata_parport: unregister devices on protocol unregister

When a protocol module registers multiple protocols and a later
registration fails, the rollback path unregisters the protocol but leaves
dynamically created devices untouched. Later removal of these dangling
devices dereferences freed module memory, crashing the kernel. This commit
tears down all pi_adapters using the protocol before unregistering the
driver.

> diff --git a/drivers/ata/pata_parport/pata_parport.c b/drivers/ata/pata_parport/pata_parport.c
> index 046ab7e3adbcf..712209882ab75 100644
> --- a/drivers/ata/pata_parport/pata_parport.c
> +++ b/drivers/ata/pata_parport/pata_parport.c
[ ... ]

While reviewing this, I noticed a pre-existing issue in pata_parport_attach():

drivers/ata/pata_parport/pata_parport.c:pata_parport_attach() {
    ...
	mutex_lock(&pi_mutex);
	id = idr_alloc(&parport_list, port, port->number, port->number,
		       GFP_KERNEL);
	if (id < 0) {
    ...
}

[Severity: High]
This is a pre-existing issue, but does this idr_alloc() call fail for all
parports except port 0?

Since the end parameter of idr_alloc() is exclusive, when port->number > 0,
it computes max = end - 1. Because start is equal to port->number, the
condition start > max evaluates to true, causing it to return -ENOSPC.

Would this cause attaching any parport with a number greater than 0 to
silently fail and completely break functionality for those ports?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1788867690.git.xiaopei01@kylinos.cn?part=2

  reply	other threads:[~2026-09-08 12:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 11:47 [PATCH v2 0/2] ata: pata_parport: fix UAF on protocol module unload Pei Xiao
2026-09-08 11:47 ` [PATCH v2 1/2] ata: pata_parport: pin the protocol module before device_register() Pei Xiao
2026-09-08 11:47 ` [PATCH v2 2/2] ata: pata_parport: unregister devices on protocol unregister Pei Xiao
2026-09-08 12:08   ` sashiko-bot [this message]
2026-09-09 10:48     ` Niklas Cassel
2026-09-09 10:52 ` [PATCH v2 0/2] ata: pata_parport: fix UAF on protocol module unload Niklas Cassel
2026-09-10 17:19   ` Niklas Cassel

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=20260908120855.9F34F1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=xiaopei01@kylinos.cn \
    /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.