Linux SCSI subsystem development
 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 5/5] scsi: aic94xx: check that an ESCB lookup returned an ESCB
Date: Thu, 15 Oct 2026 08:55:53 +0000	[thread overview]
Message-ID: <sashiko-outbox-172524@kernel.org> (raw)
In-Reply-To: <20261015081935.4168771-6-yhlee@isslab.korea.ac.kr>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: aic94xx: UAF race condition due to lockless escb access
--

commit 61c788d589a8ac9597298b6297ce45bf72a70621
Author: Yehyeong Lee <yhlee@isslab.korea.ac.kr>

scsi: aic94xx: check that an ESCB lookup returned an ESCB

This commit adds checks to verify that an ESCB lookup actually returns an
Empty SCB by inspecting the opcode.

> diff --git a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c
> --- a/drivers/scsi/aic94xx/aic94xx_task.c
> +++ b/drivers/scsi/aic94xx/aic94xx_task.c
> @@ -170,6 +170,14 @@ static void asd_get_response_tasklet(struct asd_ascb *ascb,
>  		return;
>  	}
>  
> +	if (escb->scb->header.opcode != EMPTY_SCB) {

[Severity: High]
Does checking the escb->scb->header.opcode outside of the tc_index_lock
introduce a race condition?

If the hardware returns a bogus index corresponding to a live task, could
that task concurrently time out and be freed while we are evaluating the
opcode? This appears to introduce a use-after-free read when dereferencing
escb->scb since the tc_index_lock was already dropped earlier in
asd_get_response_tasklet().

> +		ASD_DPRINTK("index_escb %d is not an ESCB, opcode is 0x%x!\n",
> +			    le16_to_cpu(resp_sb->index_escb),
> +			    escb->scb->header.opcode);
> +		ts->stat = SAS_INTERRUPTED;
> +		return;
> +	}
> +

[ ... ]

> diff --git a/drivers/scsi/aic94xx/aic94xx_tmf.c b/drivers/scsi/aic94xx/aic94xx_tmf.c
> --- a/drivers/scsi/aic94xx/aic94xx_tmf.c
> +++ b/drivers/scsi/aic94xx/aic94xx_tmf.c
> @@ -282,6 +282,13 @@ static int asd_get_tmf_resp_tasklet(struct asd_ascb *ascb,
>  		return res;
>  	}
>  
> +	if (escb->scb->header.opcode != EMPTY_SCB) {

[Severity: High]
Can this lockless access to escb->scb in asd_get_tmf_resp_tasklet() also
risk a use-after-free if the escb is concurrently freed?

> +		ASD_DPRINTK("index_escb %d is not an ESCB, opcode is 0x%x!\n",
> +			    le16_to_cpu(resp_sb->index_escb),
> +			    escb->scb->header.opcode);
> +		return res;
> +	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015081935.4168771-1-yhlee@isslab.korea.ac.kr?part=5

      reply	other threads:[~2026-10-15  8:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  8:19 [PATCH v2 0/5] scsi: aic94xx: validate the indices the sequencer supplies Yehyeong Lee
2026-10-15  8:19 ` [PATCH v2 1/5] scsi: aic94xx: bail out of escb_tasklet_complete() on a bad EDB index Yehyeong Lee
2026-10-15  8:19 ` [PATCH v2 2/5] scsi: aic94xx: validate the EDB index in asd_get_response_tasklet() Yehyeong Lee
2026-10-15  8:19 ` [PATCH v2 3/5] scsi: aic94xx: validate the EDB index in asd_get_tmf_resp_tasklet() Yehyeong Lee
2026-10-15  8:19 ` [PATCH v2 4/5] scsi: aic94xx: bound the transaction context index from the sequencer Yehyeong Lee
2026-10-15  8:19 ` [PATCH v2 5/5] scsi: aic94xx: check that an ESCB lookup returned an ESCB Yehyeong Lee
2026-10-15  8:55   ` sashiko-bot [this message]

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-172524@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox