From: sashiko-bot@kernel.org
To: "Bart Van Assche" <bvanassche@acm.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v4 5/6] scsi: core: Protect host state changes with the host lock
Date: Fri, 31 Jul 2026 22:05:20 +0000 [thread overview]
Message-ID: <20260731220520.89C831F00AC4@smtp.kernel.org> (raw)
In-Reply-To: <970cc36fb627fae64b4957954483c74cf8e59c87.1785534721.git.bvanassche@acm.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The commit message claims to use READ_ONCE() for all SCSI host state reads, but scsi_host_set_state() still performs a plain read.
--
--- Patch [5]: [PATCH v4 5/6] scsi: core: Protect host state changes with the host lock ---
commit 89fe98af4d7aa30cc00f86bd2b550ec8e90c44ff
Author: Bart Van Assche <bvanassche@acm.org>
scsi: core: Protect host state changes with the host lock
This commit annotates the SCSI host state with __guarded_by(host_lock)
and protects state changes with the host lock. It also updates state
accesses to use READ_ONCE() and WRITE_ONCE() to prevent data races.
Closes: https://lore.kernel.org/all/36d59d0e.6db0.19cdbeee01b.Coremail.luckd0g@163.com/
> Some but not all SCSI host state changes are protected with the SCSI
> host lock. Annotate the SCSI host state with __guarded_by(host_lock),
> protect all SCSI host state changes with the SCSI host lock and use
> READ_ONCE() for all SCSI host state reads. This patch prevents that
> KCSAN complains about data races when accessing the SCSI host state.
[Severity: Low]
This isn't a bug, but the commit message states that READ_ONCE() is used for
all SCSI host state reads. However, looking at scsi_host_set_state() in
drivers/scsi/hosts.c, the initial state read still uses a plain access:
int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state)
{
enum scsi_host_state oldstate = shost->shost_state;
While this is safe since the host lock is held here, should this read also be
updated to match the commit message, or should the commit message be
adjusted to reflect this exception?
> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
> index 08ec144f7bf77..9ea161478a10a 100644
> --- a/drivers/scsi/hosts.c
> +++ b/drivers/scsi/hosts.c
> @@ -145,7 +145,7 @@ int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state)
> }
> break;
> }
> - shost->shost_state = state;
> + WRITE_ONCE(shost->shost_state, state);
> return 0;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/68f3346cab2be570839350831f82b6c9233832ed.1785534721.git.bvanassche@acm.org?part=5
next prev parent reply other threads:[~2026-07-31 22:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 21:52 [PATCH v4 0/6] Enable lock context analysis in the SCSI core and UFS driver Bart Van Assche
2026-07-31 21:52 ` [PATCH v4 1/6] ufs: core: Set task state before io_schedule_timeout() Bart Van Assche
2026-07-31 21:52 ` [PATCH v4 2/6] ufs: core: Enable lock context analysis Bart Van Assche
2026-07-31 21:52 ` [PATCH v4 3/6] scsi: core: Pass the SCSI host pointer directly Bart Van Assche
2026-07-31 21:52 ` [PATCH v4 4/6] scsi: core: Add lock context annotations Bart Van Assche
2026-07-31 22:07 ` sashiko-bot
2026-07-31 21:52 ` [PATCH v4 5/6] scsi: core: Protect host state changes with the host lock Bart Van Assche
2026-07-31 22:05 ` sashiko-bot [this message]
2026-07-31 21:52 ` [PATCH v4 6/6] scsi: core: Enable lock context analysis Bart Van Assche
2026-07-31 22:05 ` sashiko-bot
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=20260731220520.89C831F00AC4@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bvanassche@acm.org \
--cc=linux-scsi@vger.kernel.org \
--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.