Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Praneeth Balasubramanian" <praneethb2002@gmail.com>
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org
Subject: Re: [PATCH 9/9] scsi: target: core: Fix PRgeneration race in REGISTER AND MOVE
Date: Sat, 05 Dec 2026 06:56:01 +0000	[thread overview]
Message-ID: <sashiko-outbox-251163@kernel.org> (raw)
In-Reply-To: <20261205063229.2518424-10-praneethb2002@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] scsi: target: Fixes tag cites c66ac9db8d4a instead of
  80bfdfa92481
- [Low] scsi: target: commit message misstates why dev_reservation_lock
  is dropped
--

commit e83f3eaab7fd314e9d7dc42d01ed8d39bfaed9af
Author: Praneeth Balasubramanian <praneethb2002@gmail.com>

> scsi: target: core: Fix PRgeneration race in REGISTER AND MOVE
>
> __core_scsi3_add_registration() increments dev->t10_pr.pr_generation
> with no lock held when it runs for a REGISTER AND MOVE. The old comment
> says dev_reservation_lock is already held in that case. That is not
> true. core_scsi3_emulate_pro_register_and_move() drops the lock before
> calling core_scsi3_alloc_registration() because the allocation can
> sleep. It only takes it back afterwards.

[Severity: Low]
Is this description of why dev_reservation_lock is dropped accurate?

core_scsi3_emulate_pro_register_and_move() calls
core_scsi3_alloc_registration() with all_tg_pt=0, so the registration is
allocated with GFP_ATOMIC and the sleeping ALL_TG_PT=1 path is skipped.

The lock drop came from 80bfdfa92481 ("target/pr: Use atomic bitop for
se_dev_entry->deve_flags reservation check"), not from a sleeping
allocation.

>
> The unlocked increment can race with core_scsi3_pr_generation(), which
> updates the same counter under dev_reservation_lock for a plain
> REGISTER. Both updates can read the same value and one increment is
> lost. READ KEYS then reports an incorrect PRgeneration. The effect is
> functional only and it takes a remote initiator to trigger it.
>
> Always take the generation from core_scsi3_pr_generation() and drop the
> register_move special case along with the stale comment. No caller of
> __core_scsi3_add_registration() holds dev_reservation_lock here. The
> register_move=0 path in the same function already calls
> core_scsi3_pr_generation() in this spot, so taking the lock cannot
> deadlock.
>
> This was found by an LLM-based audit that checks code against the rules
> stated in kernel comments.
>
> Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6")
> Cc: stable@vger.kernel.org
> Signed-off-by: Praneeth Balasubramanian <praneethb2002@gmail.com>

[Severity: Low]
Should the Fixes tag cite 80bfdfa92481 ("target/pr: Use atomic bitop for
se_dev_entry->deve_flags reservation check") instead of c66ac9db8d4a
("[SCSI] target: Add LIO target core v4.0.0-rc6")?

In the initial LIO import, core_scsi3_emulate_pro_register_and_move()
still held dev->dev_reservation_lock across
core_scsi3_alloc_registration().  Backporting this patch to a kernel
before the deve_flags commit would self-deadlock on that lock.

  Fixes: 80bfdfa92481 ("target/pr: Use atomic bitop for se_dev_entry->deve_flags reservation check")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205063229.2518424-1-praneethb2002@gmail.com?part=9

      reply	other threads:[~2026-12-05  6:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  6:32 [PATCH 0/9] scsi: fix missing locking and dump length checks in several drivers Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 1/9] scsi: bnx2i: Hold the session back_lock around iscsi_itt_to_task() Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 2/9] scsi: mpt3sas: do not keep an enclosure pointer across a host reset Praneeth Balasubramanian
2026-12-05  6:46   ` sashiko-bot
2026-12-05  6:32 ` [PATCH 3/9] scsi: pmcraid: Take host_lock around scsi_report_bus_reset() Praneeth Balasubramanian
2026-12-05  6:43   ` sashiko-bot
2026-12-05  6:32 ` [PATCH 4/9] scsi: ipr: Skip dump entries whose length is not a 4 byte multiple Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 5/9] scsi: arm: Fix eh_abort race against the interrupt handler Praneeth Balasubramanian
2026-12-05  6:50   ` sashiko-bot
2026-12-05  6:32 ` [PATCH 6/9] scsi: csiostor: hold hw lock when issuing port stats mailbox command Praneeth Balasubramanian
2026-12-05  6:47   ` sashiko-bot
2026-12-05  6:32 ` [PATCH 7/9] scsi: fnic: Hold fnic_lock for the oxid calls in the FIP timer work Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 8/9] scsi: qla2xxx: Hold qp_lock when completing command in abort timeout Praneeth Balasubramanian
2026-12-05  6:58   ` sashiko-bot
2026-12-05  6:32 ` [PATCH 9/9] scsi: target: core: Fix PRgeneration race in REGISTER AND MOVE Praneeth Balasubramanian
2026-12-05  6:56   ` sashiko-bot [this message]

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-251163@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=praneethb2002@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=target-devel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox