From: sashiko-bot@kernel.org
To: "Phil Pemberton" <philpem@philpem.me.uk>
Cc: linux-scsi@vger.kernel.org, dlemoal@kernel.org,
cassel@kernel.org, linux-ide@vger.kernel.org
Subject: Re: [PATCH v9 05/11] scsi: sr: retry unfinished media revalidation on the next open
Date: Tue, 06 Oct 2026 23:52:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-162532@kernel.org> (raw)
In-Reply-To: <20261006234202.1139018-6-philpem@philpem.me.uk>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] scsi: sr: uninitialized stack memory read of sshdr in sr_revalidate_disk()
--
commit 6831e2d4751ec5b84e9b7b08a5e93e7b6123ef75
Author: Phil Pemberton <philpem@philpem.me.uk>
scsi: sr: retry unfinished media revalidation on the next open
This commit updates the scsi sr driver to keep media revalidation pending
until it completes, handling cases where a new disc is still spinning up.
It introduces a mechanism to return -ENOMEDIUM for blocking opens if the
drive reports it is becoming ready, ensuring the queue limits update is
eventually completed.
[Severity: Medium]
Could the new check in sr_revalidate_disk() result in an uninitialized stack
memory read if the scsi command fails early?
In drivers/scsi/sr.c at line 485 within sr_revalidate_disk(), the code
evaluates scsi_sense_valid(&sshdr) and reads sshdr.sense_key, sshdr.asc,
and sshdr.ascq. However, sshdr is allocated on the stack without
zero-initialization.
If scsi_test_unit_ready() encounters an early failure (such as an allocation
failure in scsi_alloc_request() returning -ENOMEM or -ENXIO), it returns the
negative error code immediately without populating sshdr. Since the new logic
checks scsi_sense_valid() whenever scsi_test_unit_ready() returns non-zero,
it will read the uninitialized sshdr.response_code.
If the random stack data happens to match the 0x70 mask required by
scsi_sense_valid(), the code will further evaluate the uninitialized
sense_key, asc, and ascq fields. Can this cause unrelated errors to be
incorrectly masked as -ENOMEDIUM, or trigger KMSAN uninitialized memory
warnings?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261006234202.1139018-1-philpem@philpem.me.uk?part=5
next prev parent reply other threads:[~2026-10-06 23:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 23:41 [PATCH v9 00/11] ata: add multi-LUN support for ATAPI devices Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 01/11] ata: libata-core: pin SCSI devices during port detach Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 02/11] ata: libata-zpodd: reference SCSI devices in PM callbacks Phil Pemberton
2026-10-06 23:59 ` sashiko-bot
2026-10-06 23:41 ` [PATCH v9 03/11] scsi: scsi_devinfo: preserve full-width quirk identifiers Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 04/11] scsi: sr: initialize logical block size before registering the disk Phil Pemberton
2026-10-06 23:53 ` sashiko-bot
2026-10-06 23:41 ` [PATCH v9 05/11] scsi: sr: retry unfinished media revalidation on the next open Phil Pemberton
2026-10-06 23:52 ` sashiko-bot [this message]
2026-10-06 23:41 ` [PATCH v9 06/11] ata: libata-scsi: add atapi_max_lun module parameter Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 07/11] ata: libata-scsi: convert dev->sdev to per-LUN array Phil Pemberton
2026-10-06 23:58 ` sashiko-bot
2026-10-07 2:38 ` Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 08/11] ata: libata-scsi: route non-zero LUN commands for multi-LUN ATAPI Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 09/11] scsi: add BLIST_NO_LUN_1F blacklist flag Phil Pemberton
2026-10-06 23:42 ` [PATCH v9 10/11] ata: libata-scsi: probe additional LUNs for multi-LUN ATAPI devices Phil Pemberton
2026-10-06 23:42 ` [PATCH v9 11/11] scsi: scsi_devinfo: add COMPAQ PD-1 multi-LUN ATAPI device quirk Phil Pemberton
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-162532@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=philpem@philpem.me.uk \
--cc=sashiko-reviews@lists.linux.dev \
/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.