From: Igor Pylypiv <ipylypiv@google.com>
To: Niklas Cassel <cassel@kernel.org>
Cc: Jack Wang <jinpu.wang@cloud.ionos.com>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Salomon Dushimirimana <salomondush@google.com>,
Terrence Adams <tadamsjr@google.com>,
Damien Le Moal <dlemoal@kernel.org>,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH 2/5] scsi: pm80xx: Fix array-index-out-of-of-bounds on rmmod
Date: Wed, 13 Aug 2025 12:43:42 -0700 [thread overview]
Message-ID: <aJzq7t3nFoFVAQQT@google.com> (raw)
In-Reply-To: <20250813114107.916919-9-cassel@kernel.org>
On Wed, Aug 13, 2025 at 01:41:09PM +0200, Niklas Cassel wrote:
> Since commit f7b705c238d1 ("scsi: pm80xx: Set phy_attached to zero when
> device is gone") UBSAN reports:
> UBSAN: array-index-out-of-bounds in drivers/scsi/pm8001/pm8001_sas.c:786:17
> index 28 is out of range for type 'pm8001_phy [16]'
> on rmmod when using an expander.
>
> For a direct attached device, attached_phy contains the local phy id.
> For a device behind an expander, attached_phy contains the remote phy id,
> not the local phy id.
>
> I.e. while pm8001_ha will have pm8001_ha->chip->n_phy local phys, for a
> device behind an expander, attached_phy can be much larger than
> pm8001_ha->chip->n_phy (depending on the amount of phys of the expander).
>
> E.g. on my system pm8001_ha has 8 phys with phy ids 0-7.
> One of the ports has an expander connected.
> The expander has 31 phys with phy ids 0-30.
>
> The pm8001_ha->phy array only contains the phys of the HBA.
> It does not contain the phys of the expander.
> Thus, it is wrong to use attached_phy to index the pm8001_ha->phy array
> for a device behind an expander.
>
> Thus, we can only clear phy_attached for devices that are directly
> attached.
>
> Fixes: f7b705c238d1 ("scsi: pm80xx: Set phy_attached to zero when device is gone")
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Igor Pylypiv <ipylypiv@google.com>
next prev parent reply other threads:[~2025-08-13 19:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 11:41 [PATCH 0/5] scsi: pm80xx: Fix expander support Niklas Cassel
2025-08-13 11:41 ` [PATCH 1/5] scsi: pm80xx: Restore support for expanders Niklas Cassel
2025-08-13 19:42 ` Igor Pylypiv
2025-08-13 11:41 ` [PATCH 2/5] scsi: pm80xx: Fix array-index-out-of-of-bounds on rmmod Niklas Cassel
2025-08-13 19:43 ` Igor Pylypiv [this message]
2025-08-13 11:41 ` [PATCH 3/5] scsi: pm80xx: Add helper function to get the local phy id Niklas Cassel
2025-08-13 19:44 ` Igor Pylypiv
2025-08-14 2:03 ` Damien Le Moal
2025-08-13 11:41 ` [PATCH 4/5] scsi: pm80xx: Fix pm8001_abort_task() for chip_8006 when using an expander Niklas Cassel
2025-08-13 19:47 ` Igor Pylypiv
2025-08-13 11:41 ` [PATCH 5/5] scsi: pm80xx: Use pm80xx_get_local_phy_id() to access phy array Niklas Cassel
2025-08-13 19:48 ` Igor Pylypiv
2025-08-14 2:12 ` Damien Le Moal
2025-08-14 8:26 ` [PATCH 0/5] scsi: pm80xx: Fix expander support Damien Le Moal
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=aJzq7t3nFoFVAQQT@google.com \
--to=ipylypiv@google.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=jinpu.wang@cloud.ionos.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=salomondush@google.com \
--cc=tadamsjr@google.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.