From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796453762; b=XkoH8o0UoOUuPHYSEV5Rgq5WridvJFESiIi+kV8XhmNid4GG+YTqsDGzKwVleM1ggvNE FJi8PZ0phz7ePYVywMX+WJE5PaipYvzncaZ+lX18+x1+DfQbNfVIkon1g3skuJIrMDjvw s5Ah/DB3MBjdK+x3DRm+V2t17+GbOKJSKmbphuLXUT3LBtPR+oCoIOeFaxEz2LV2ETPN0 EaTsrDRnOnzhzeFaR+Ol+jsnaAIYnwvvCxwAB/O1IDiE7GbOx8e6fePPj9qsChbgioz8d jJdxMFuJHflB7IPPQ+pO/6bWPq1TUlw+tBqPzkroMBJNiL9WqPiDzKRby7LN6GEkymg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796453762; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=u0+11bN4nPBxmRvo4j2rUlfWNI5wsUgv0mk65c32KO8=; b=yrtvZWJioSOWY6yXCuNBIJa/Grw7PETMiFf+RMIYRSYS4QV6hfSFSgcnxRAHbHHMiLCT mFAwnE5pc8bR+SsGzPOfzTkWDkjFG+y1lTzGELgnGxMPjueTtJD6DqS/xVROrY4eihXaS kfC37xkFar1zWH7h41vq3UAvlgE9GFkSl0TUOVScOJdHbKgGjlKfsJ1PHonyAN0bjzJ3V hIEHBCQNqlqEVwJ8tsRZ0rLQGIblql3uP2WJVQhABGtMSGEdecC7qTj2tn4+6BXRMOXbz vSQN+JTLTQTu9nMpWxnQeN9J/iTensmSo8ASK+cXlpQAf1YuUzd04oT4VFa5ZPw6Kjw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=A6THnzSc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5863F606A691; Sat, 5 Dec 2026 06:56:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=A6THnzSc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FFE81F00A13; Sat, 5 Dec 2026 06:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796453762; bh=u0+11bN4nPBxmRvo4j2rUlfWNI5wsUgv0mk65c32KO8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=A6THnzSc4vfKu9tQabyz3EKWYU23c8Mq9Y6IhBFn/HfcZF8Q57X2KaTtKLl0hHEqu TPIoXLgwk7OmDYzrl7800kQFEd+Dtgxnd97a9AGR3ZZFlwtiPSgXAYGGJ8b3Lq57SZ jEbnCMolfkgXdUgb2t9/kh3M7D45jW1Qdg55TU1AzAprfWrYH/Ivn3kSs5cSD9oqKZ Ojk/YWOWUU/sCiZ8e1ekev+KmHsWdjuIphfEO9nj2k2475z4imM/HHnc7ClfX9+UnS o9xQln9HzuHW0qByQpAGNwlKVuxVOklZ7ylWvqjmnJTE7/PLo1J12SUN6r5CGDVVk4 CmeiL+SL2NV4Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 9/9] scsi: target: core: Fix PRgeneration race in REGISTER AND MOVE Reply-To: sashiko-reviews@lists.linux.dev To: "Praneeth Balasubramanian" Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org In-Reply-To: <20261205063229.2518424-10-praneethb2002@gmail.com> References: <20261205063229.2518424-1-praneethb2002@gmail.com> <20261205063229.2518424-10-praneethb2002@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 06:56:01 +0000 X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 > 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=3D0, so the registration is allocated with GFP_ATOMIC and the sleeping ALL_TG_PT=3D1 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=3D0 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 [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") --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205063229.2518= 424-1-praneethb2002@gmail.com?part=3D9