All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yehyeong Lee" <yhlee@isslab.korea.ac.kr>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 2/3] scsi: arcmsr: check the completion index the adapter reports
Date: Mon, 12 Oct 2026 09:14:48 +0000	[thread overview]
Message-ID: <sashiko-outbox-167888@kernel.org> (raw)
In-Reply-To: <a9c7e18a8f392d216301a3e08b69a47d7981e1c9.1791792888.git.yhlee@isslab.korea.ac.kr>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] scsi: arcmsr: incomplete bounds check allows NULL pointer dereference
--

commit 12ade927afc5ca1b453d068ce2fc5d1af8777cd0
Author: Yehyeong Lee <yhlee@isslab.korea.ac.kr>

scsi: arcmsr: check the completion index the adapter reports

This commit adds bounds checks in the interrupt and polling handlers for
adapter types E and F. It validates that the completion index reported by
the adapter does not exceed ARCMSR_MAX_FREECCB_NUM to prevent out-of-bounds
array accesses when retrieving command control blocks.

> diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
> index 255f1d898079f..9519715883b5a 100644
> --- a/drivers/scsi/arcmsr/arcmsr_hba.c
> +++ b/drivers/scsi/arcmsr/arcmsr_hba.c
> @@ -2677,6 +2677,14 @@ static void arcmsr_hbaE_postqueue_isr(struct AdapterControlBlock *acb)
>  	pmu = acb->pmuE;
>  	while ((readl(&pmu->reply_post_producer_index) & 0xFFFF) != doneq_index) {
>  		cmdSMID = acb->pCompletionQ[doneq_index].cmdSMID;
> +		if (cmdSMID >= ARCMSR_MAX_FREECCB_NUM) {

[Severity: Critical]
Is this bounds check tight enough?

The commit message notes the choice to bound against ARCMSR_MAX_FREECCB_NUM
(1024) instead of acb->maxFreeCCB. However, the acb->pccb_pool array is
only populated up to acb->maxFreeCCB (which defaults to 192).

This leaves array elements between acb->maxFreeCCB and 1023 uninitialized
and set to NULL. If a malfunctioning or malicious adapter sends a cmdSMID
in this gap (e.g., 200), it bypasses this bounds check.

The driver will then retrieve a NULL pointer for the CCB and blindly
dereference it in arcmsr_drain_donequeue():

drivers/scsi/arcmsr/arcmsr_hba.c:arcmsr_drain_donequeue()
    if ((pCCB->acb != acb) || (pCCB->startdone != ARCMSR_CCB_START)) {
        ...

Could this regression lead to a NULL pointer dereference panic? Would it
make sense to add a check to ensure the retrieved CCB pointer is not NULL
before passing it to arcmsr_drain_donequeue(), or enforce a stricter bound
that correctly handles the uninitialized pool entries?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791792888.git.yhlee@isslab.korea.ac.kr?part=2

  reply	other threads:[~2026-10-12  9:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12  9:01 [PATCH v2 0/3] scsi: arcmsr: bound adapter-supplied completion indices and message lengths Yehyeong Lee
2026-10-12  9:01 ` [PATCH v2 1/3] scsi: arcmsr: bound the firmware-supplied message length Yehyeong Lee
2026-10-12  9:14   ` sashiko-bot
2026-10-12  9:01 ` [PATCH v2 2/3] scsi: arcmsr: check the completion index the adapter reports Yehyeong Lee
2026-10-12  9:14   ` sashiko-bot [this message]
2026-10-12  9:01 ` [PATCH v2 3/3] scsi: arcmsr: wrap the type B completion index before using it Yehyeong Lee
2026-10-12  9:18   ` 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=sashiko-outbox-167888@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yhlee@isslab.korea.ac.kr \
    /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.