[lvc-project] [PATCH 6.1 v2 3/3] scsi: aic79xx: check for non-NULL scb in ahd_linux_queue_abort_cmd
Fedor Pchelkin
pchelkin at ispras.ru
Mon Apr 21 13:08:35 MSK 2025
On Mon, 21. Apr 15:16, Boris Belyavtsev wrote:
> possible NULL pointer dereference in case hardware returns invalid scb
> index.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 73a254621007 ("[SCSI] aic79xx: update to use scsi_transport_spi")
> Signed-off-by: Boris Belyavtsev <bbelyavtsev at usergate.com>
> ---
> drivers/scsi/aic7xxx/aic79xx_osm.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
> index 17dfc3c72110..f2ae202d2641 100644
> --- a/drivers/scsi/aic7xxx/aic79xx_osm.c
> +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
> @@ -2265,7 +2265,8 @@ ahd_linux_queue_abort_cmd(struct scsi_cmnd *cmd)
Дострою фрагмент:
/*
* At this point, pending_scb is the scb associated with the
* passed in command. That command is currently active on the
* bus or is in the disconnected state.
*/
ahd_inb(ahd, SAVED_SCSIID);
if (last_phase != P_BUSFREE
&& SCB_GET_TAG(pending_scb) == active_scbptr) {
/*
* We're active on the bus, so assert ATN
> * and hope that the target responds.
> */
> pending_scb = ahd_lookup_scb(ahd, active_scbptr);
> - pending_scb->flags |= SCB_RECOVERY_SCB|SCB_ABORT;
> + if (pending_scb != NULL)
> + pending_scb->flags |= SCB_RECOVERY_SCB|SCB_ABORT;
Ну, то есть этот if-блок покрывает "currently active on the bus". И
драйвер *подразумевает*, что соответствующий scb будет получен. Иначе
это свидетельствует о серьёзной ошибке, к обработке которой он не
приспособлен (нужно с нуля переписывать, грубо говоря).
Лучше какой-нибудь WARN_ON_ONCE и переход к метке out, думаю.
> ahd_outb(ahd, MSG_OUT, HOST_MSG);
> ahd_outb(ahd, SCSISIGO, last_phase|ATNO);
> scmd_printk(KERN_INFO, cmd, "Device is active, asserting ATN\n");
> --
> 2.43.0
More information about the lvc-project
mailing list