All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] scsi: aic94xx: validate the indices the sequencer supplies
@ 2026-10-15  8:19 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
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Yehyeong Lee @ 2026-10-15  8:19 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, linux-kernel, stable, yhlee

This supersedes

  [PATCH 0/3] scsi: aic94xx: validate the sequencer-supplied EDB index
  <20261015072612.4144043-1-yhlee@isslab.korea.ac.kr>

which should be dropped: its patch 2 was wrong in a way worth stating
plainly.

aic94xx takes two numbers out of the done list the sequencer writes and
uses both without looking at them.  One is the empty data buffer index,
which v1 bounded in three places.  The other is the transaction context
index, which v1 did not touch, and which turns out to be the same class of
problem one level up.

 1  escb_tasklet_complete() already noticed a bad EDB index and printed
    about it, then fell through and used it anyway.  Add the missing
    return.  Unchanged from v1.
 2  asd_get_response_tasklet() never looked.  Bound it -- and, new in v2,
    report SAS_INTERRUPTED on the way out.
 3  asd_get_tmf_resp_tasklet() never looked either.  Unchanged from v1.
 4  asd_tc_index_find() indexes tc_index_array[] with the number the
    sequencer echoes back, in all three of its callers, without a bound.
    New in v2.
 5  the pointer that comes back is used as an Empty SCB without checking
    that it is one, and struct scb is a union.  New in v2.

On patch 2, the correction.  v1's bail returned without touching ts->stat,
and asd_task_tasklet_complete() has already set ts->resp to
SAS_TASK_COMPLETE and ts->stat to SAS_PROTO_RESPONSE by then.  That status
is a promise that this function will fill in the real one.  For SSP,
sas_end_task() starts from DID_OK and SAS_SAM_STAT_GOOD and its
SAS_PROTO_RESPONSE arm only prints a notice, so the command completes as a
success.  For STP, sas_ata_task_done() takes SAS_PROTO_RESPONSE to mean the
ending FIS holds the status and copies ATA_RESP_FIS_SIZE out of a ts->buf
that was never written.  So a hardening patch turned a bad index into a
silently successful command, which is worse than what it was fixing.  v2
reports SAS_INTERRUPTED instead, which is what this driver already uses for
a response that arrived and could not be used, and it does the same for the
lookup failure above it, which had the same hole before this series
existed.

Patches 4 and 5 finish the class rather than leaving half of it.  The index
in question is one the driver itself allocated and handed to the sequencer
in scb->header.index, so it comes back echoed; asd_tc_index_find() reads
tc_index_array[] with it, the array has hw_prof.max_scbs entries, and
max_scbs cannot exceed 5957 while the field is a __le16.  All three callers
of that helper already handle a NULL return, so the bound needs no caller
changes.  Patch 5 adds the opcode check that asd_dl_tasklet_handler()
already does.

I have not reproduced any of this on a controller.  Injecting the three bad
values through a KUnit test on a KASAN kernel does reach
seq->edb_arr[-1] and tc_index_array[] past its end, and does leave a
non-Empty SCB modified, which shows the arithmetic and the missing checks
are real; it does not show that the sequencer emits those values, and
nothing in the tree answers that, since it is firmware loaded with
request_firmware() and there is no Documentation/ file or MAINTAINERS entry
for this driver.  The commit messages are written on that basis and claim
no reachable memory error.

Patch 1 keeps Cc: stable, as in v1.  Patches 4 and 5 carry it too: unlike
the EDB bound, those two are an unchecked array index and a union
reinterpretation that the driver never guarded at all.  Patches 2 and 3
still do not, and I would rather a maintainer decide.

Yehyeong Lee (5):
  scsi: aic94xx: bail out of escb_tasklet_complete() on a bad EDB index
  scsi: aic94xx: validate the EDB index in asd_get_response_tasklet()
  scsi: aic94xx: validate the EDB index in asd_get_tmf_resp_tasklet()
  scsi: aic94xx: bound the transaction context index from the sequencer
  scsi: aic94xx: check that an ESCB lookup returned an ESCB

 drivers/scsi/aic94xx/aic94xx_hwi.h  |  2 ++
 drivers/scsi/aic94xx/aic94xx_scb.c  |  1 +
 drivers/scsi/aic94xx/aic94xx_task.c | 16 ++++++++++++++++
 drivers/scsi/aic94xx/aic94xx_tmf.c  | 13 +++++++++++++
 4 files changed, 32 insertions(+)


base-commit: 2c3418fffa9d037b2038a6db48be63f9e2291806
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-15  8:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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.