All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Phil Pemberton" <philpem@philpem.me.uk>
Cc: cassel@kernel.org, dlemoal@kernel.org, linux-ide@vger.kernel.org
Subject: Re: [PATCH v6 4/6] scsi: add BLIST_NO_LUN_1F blacklist flag
Date: Mon, 08 Jun 2026 22:10:02 +0000	[thread overview]
Message-ID: <20260608221003.1ECFE1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260608213443.2296614-5-philpem@philpem.me.uk>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Medium] The BLIST_NO_LUN_1F flag fails to suppress the initial unpopulated LUN (usually LUN 0) from being added as a spurious 'No Device' entry.

Pre-existing issues:
- [High] Concurrent read-modify-write on `struct scsi_target` bitfields causes data races and lost updates.
--

commit 10038c8d1287bfd2d8ba061ac2b0a14d56b4076e
Author: Phil Pemberton <philpem@philpem.me.uk>
scsi: add BLIST_NO_LUN_1F blacklist flag

This commit introduces the BLIST_NO_LUN_1F blacklist flag to suppress spurious
"No Device" entries on certain multi-LUN devices. It modifies scsi_add_lun()
to set the pdt_1f_for_no_lun flag during LUN scan based on the new blacklist
flag.

> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index ef22a4228b855..bfbbf9be05d21 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -1069,6 +1069,8 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
>  	transport_configure_device(&sdev->sdev_gendev);
>  
>  	sdev->sdev_bflags = *bflags;
> +	if (sdev->sdev_bflags & BLIST_NO_LUN_1F)
> +		sdev->sdev_target->pdt_1f_for_no_lun = 1;

[Severity: Medium]
Will this actually suppress the spurious entry for the first scanned LUN
(typically LUN 0)?

Looking at scsi_probe_and_add_lun(), the suppression check evaluates
starget->pdt_1f_for_no_lun before scsi_add_lun() is called:

scsi_probe_and_add_lun() {
    ...
    if (((result[0] >> 5) == 1 || starget->pdt_1f_for_no_lun) &&
        ...
        /* skip LUN */
        return SCSI_SCAN_TARGET_PRESENT;
    ...
    scsi_add_lun(...);
}

If LUN 0 is unpopulated, does it bypass the suppression check since the flag
is only set here in scsi_add_lun() afterward?

[Severity: High]
This is a pre-existing issue, but does adding another non-atomic bitfield
modification here expand a race window?

The fields pdt_1f_for_no_lun, single_lun, and expecting_lun_change are
adjacent bitfields in struct scsi_target that share the same memory word.
Modifying a bitfield performs a non-atomic read-modify-write.

Since scsi_add_lun() modifies pdt_1f_for_no_lun and single_lun from process
context (e.g., during a rescan), and an I/O completion on an already-active
LUN encountering a Unit Attention might call scsi_report_lun_change() which
modifies expecting_lun_change from softirq context, can this concurrent
read-modify-write cause updates to be lost?

If expecting_lun_change is lost, does it result in failing commands with
spurious I/O errors instead of retrying them?

If single_lun is lost, could it allow concurrent I/O to devices that do not
support it, potentially causing device hangs or data corruption?

>  
>  	if (scsi_device_is_pseudo_dev(sdev))
>  		return SCSI_SCAN_LUN_PRESENT;

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260608213443.2296614-1-philpem@philpem.me.uk?part=4

  reply	other threads:[~2026-06-08 22:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 21:34 [PATCH v6 0/6] ata: libata-scsi: multi-LUN ATAPI device support Phil Pemberton
2026-06-08 21:34 ` [PATCH v6 1/6] ata: libata-scsi: add atapi_max_lun module parameter Phil Pemberton
2026-06-08 22:10   ` sashiko-bot
2026-06-08 21:34 ` [PATCH v6 2/6] ata: libata-scsi: convert dev->sdev to per-LUN array Phil Pemberton
2026-06-08 22:12   ` sashiko-bot
2026-06-09  7:22   ` Hannes Reinecke
2026-06-08 21:34 ` [PATCH v6 3/6] ata: libata-scsi: route non-zero LUN commands for multi-LUN ATAPI Phil Pemberton
2026-06-08 22:13   ` sashiko-bot
2026-06-09  7:24   ` Hannes Reinecke
2026-06-08 21:34 ` [PATCH v6 4/6] scsi: add BLIST_NO_LUN_1F blacklist flag Phil Pemberton
2026-06-08 22:10   ` sashiko-bot [this message]
2026-06-09  7:24   ` Hannes Reinecke
2026-06-08 21:34 ` [PATCH v6 5/6] ata: libata-scsi: probe additional LUNs for multi-LUN ATAPI devices Phil Pemberton
2026-06-08 22:17   ` sashiko-bot
2026-06-09  7:25   ` Hannes Reinecke
2026-06-08 21:34 ` [PATCH v6 6/6] 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=20260608221003.1ECFE1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=linux-ide@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.