From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452395; b=cyhsneFCPvK0ooW9qBuoPuITBOP/HiAEH8CLwe589OO1MsucHRcCNLHXoFC1oZUOXcYO 6jya94n33IHvy4vksq/in3VNqWk6AXZ3s/RHF5SmU0d9lyhUiQY1ctGLc4KCi67lXwr02 owZdMe9z39Ns6bwr2DzHZlV8bTMDnBeTRLbdjmMcx68QjSStA7fs1OAgqXMXaZvsuf1VO 7CnGbwuFEbUUuZ73fuCU6Rp7yX5zFRa/FZC3y1UgzzWrZMbGJTPnlaNO0Hhd4gulmRWYq TCECNl+3XbQIZnWZI7fn2ISkmSXFfI/VZR6hSm52w+CrkdTl9290X6FMozXMBi+aO1Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796452395; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=hdGZvvbU32EwVkqsqRK7xSwN2agPTcE0PhYG8e19bRM=; b=eG7h9LQIg9XBtO/VfFzZrhKAM2VEJxV6CRhqHymZ+yXWk5MrCCpmbvec+jClf0jAqTw+ xe3D5WqqxylV0J7qCcELLLvzuOwEPb/pUA9Fsx/lxS3U4NSWm9ey7Gd2YgGa+oSgYNFlC +thxkn91am/pDPCjxnbtMPxhHS87j383MOr1L1sEbiBfopfjvdr+um5bAMSe60hsowkz7 RMA2Ww6Lpbsar6S5l/Is2d/vkC4dMGGbNDhDTvcUX5/dUOvVshFPsYqapSnt3+xHTudoS Qx2ZdFDvQaz3+Lt6vipMBOFUkgr2j8IQGgknyKuS4QtBzvVD4s08qIVXYIDIVRx/ouA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=GWvBToJa; arc=none smtp.remote-ip=74.125.82.53 Received: from mail-dl1-f53.google.com (mail-dl1-f53.google.com [74.125.82.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2BED606A339 for ; Sat, 5 Dec 2026 06:33:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C2BED606A339 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=GWvBToJa Received: by mail-dl1-f53.google.com with SMTP id a92af1059eb24-1b5d60183f9so2080399c88.1 for ; Fri, 04 Dec 2026 22:33:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796452394; x=1797057194; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=hdGZvvbU32EwVkqsqRK7xSwN2agPTcE0PhYG8e19bRM=; b=GWvBToJaG3TXV+byArdwPhkRBDmVzoPiLZwl85yLeLxNl3D+sgUh64BQvIyJIFsnA/ W26eFhWR4SzlqxxNQF4hEnVvh7VTDPz5RMprWp1iNMRxKa234iQa/QwDwLreoJvv8LBk d6EYOpIM7FUVxJid3AoXdv5XSzkUwop0ED1BzX9DboeM+ZFyRtqNvGQZAiUlYy1P1sfX CKeErmitseNEFJvyIcjFuHf7kpF5nNLtEAzqN207VW1MfvURWU7bgc0qtc/z8PydlfTC AvbiXUGy6+SB4RVClMNkGaYIBkaydRQnupqabLkHa73vnVjzQz1GYpxEbXDSSMK1MVIF QvTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796452394; x=1797057194; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=hdGZvvbU32EwVkqsqRK7xSwN2agPTcE0PhYG8e19bRM=; b=yOfCKuU2pjoh6gy8Tq92opfp+aJPL+D6wsq3NRfM6n3TErOVHIted8BYrPZudjR21D uTeVYypX/Ak7f/H5cbVIBld8zGLeggYbMrzmdY3kfxkRFSBpHQAXQENDwFKAjjOqqEdD Y1LM3ZOld9aIngCtmYz8IPsCt7LhwSmxbKcP0y4MJiPCQtIRr2L5uhEO43bt90E3uEMX ce6yIaqz3nNIFeu5dDnbBvpDQf3UuMQ4kQ21eAbG6021wCq10c4khslbLknzc1Mu8s88 mmkyLq5nz6VvR+PfWMazxd+CYhAzcjQs15LJCIqQUzoEeV8NwCXoHU6NjMIND4pZ5wag FE2g== X-Forwarded-Encrypted: i=1; AL+hErE4LC6rRGpyK78W2ueWQig2kCvmIhh8QVyeCCSsRDS7qUkAS86mOndfRP7BkVOKHthA4GgdeeT9Ry/Rdh8=@vger.kernel.org X-Gm-Message-State: APuU4Z/hDYbbPrgkrJRSp8Q49/Kbt1ASFwW60HtB+IQai6hjXBHSY+Yu sb5lPuznRxdnn37kedZQpJUXYFo/ZqFVF9XBqZH9l9IKPW+xns7MFsZ7 X-Gm-Gg: AZFdTZftf+/F414E5Bb3bDy1uNJl25JiS4VwSIZM5+l+0Vn+K6UutZqB193r81ffL5M WNyl2ERxRc2msoB9FMZomIpY7IeD+Ri2LqqADMHxIly4nr9p0XWUObhewmsKaUt1eriZNV09M/i dfi8amNt2kvAZs+g1z4H+lv9zs693Gh9FywY1ikHO8VeTryMzNbeEfUC3CpIRdsGe8jwwTwaGn0 iYb4zaCBAydfkhSi0brwwl+wTLsCBPTm9WcqTzmo23rM1ERUYj9C5Us8VJW9eGJFtwKiw+lJq6u 05zI11UtJ25I0tgEXYCHqC5oHJcbhOXKWNmsgoOlimIIuJQIHWWDEEFtMPxHEoysQkzLBNGC7eb q6nByamYBqa7EcBY9Dq930XvBYTf1fHJ3gwS7FzRjAbbXBTs5Ab8mpNXFu0faYYR/ytN26ZfjDt PwIJJWzubauFKMG+gFWGib3rG3k25HCXGuXYGQ059CfGP1pMRxEZQCNof9E1Ia36T8LCV6evsvP pYmjpSx+fba8hY0y+QDydGW6MvNViDVSUKd2eo4aqv2kivlv+KGBPTyKufLt1oUerFU580oD2r8 FeljjnyA4a8BPg70MGxQRuwWvvIi/jAN9xM4q7tzX+BrF+Z7f1oYs1auky/zNassL7U= X-Received: by 2002:a05:701b:2406:b0:1b5:3819:f8a with SMTP id a92af1059eb24-1b5d727793fmr3044469c88.38.1796452393852; Fri, 04 Dec 2026 22:33:13 -0800 (PST) Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-387521bb842sm14612341eec.15.2026.12.04.22.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 22:33:13 -0800 (PST) From: Praneeth Balasubramanian To: Nilesh Javali , Manish Rangankar , GR-ETH-Storage-Upstream@marvell.com, "James E.J. Bottomley" , "Martin K. Petersen" Cc: Praneeth Balasubramanian , stable@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/9] scsi: bnx2i: Hold the session back_lock around iscsi_itt_to_task() Date: Fri, 4 Dec 2026 22:32:21 -0800 Message-Id: <20261205063229.2518424-2-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261205063229.2518424-1-praneethb2002@gmail.com> References: <20261205063229.2518424-1-praneethb2002@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit bnx2i_send_iscsi_tmf() looks up the task to abort with iscsi_itt_to_task(), then reads ctask->sc and the command's data direction. iscsi_itt_to_task() requires the session back_lock, but bnx2i holds only the frwd_lock here. A TODO comment and an __assume_ctx_lock() annotation mark the gap. The completion path runs under back_lock. It clears task->sc and completes the command. If it runs between the !ctask->sc check and the ref_sc load, ref_sc is NULL and the data direction read faults. Take back_lock around the lookup and the two reads. libiscsi already nests back_lock inside frwd_lock, so the lock order does not change. Remove the TODO and the annotation. This was found by an LLM-based audit that checks code against the rules stated in kernel comments. Fixes: 659743b02c41 ("[SCSI] libiscsi: Reduce locking contention in fast path") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: This was found by an LLM-based audit, part of research at UCSB SecLab. An LLM turned a kernel comment into a rule, and three LLM votes checked the code against it. The fix and changelog were drafted with GLM-5.3 and checked against the source with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64 allmodconfig), clang 23. checkpatch.pl is clean. Not runtime-tested, and there is no reproducer. I do not have this hardware. This is against linux-next, where the lock context annotations for SCSI added the TODO. In mainline the same lookup has no TODO and iscsi_itt_to_task() takes (conn, itt). The fix is the same there. drivers/scsi/bnx2i/bnx2i_hwi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c index c22f1c981d02..70bc5e5f9b8b 100644 --- a/drivers/scsi/bnx2i/bnx2i_hwi.c +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c @@ -405,13 +405,10 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn, switch (tmfabort_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) { case ISCSI_TM_FUNC_ABORT_TASK: case ISCSI_TM_FUNC_TASK_REASSIGN: - /* - * TODO: hold session->back_lock around the iscsi_itt_to_task() - * call below. - */ - __assume_ctx_lock(&session->back_lock); + spin_lock_bh(&session->back_lock); ctask = iscsi_itt_to_task(session, conn, tmfabort_hdr->rtt); - if (!ctask || !ctask->sc) + if (!ctask || !ctask->sc) { + spin_unlock_bh(&session->back_lock); /* * the iscsi layer must have completed the cmd while * was starting up. @@ -421,6 +418,7 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn, * In this case, the task must be aborted */ return 0; + } ref_sc = ctask->sc; if (ref_sc->sc_data_direction == DMA_TO_DEVICE) @@ -429,6 +427,7 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn, else dword = (ISCSI_TASK_TYPE_READ << ISCSI_CMD_REQUEST_TYPE_SHIFT); + spin_unlock_bh(&session->back_lock); tmfabort_wqe->ref_itt = (dword | (tmfabort_hdr->rtt & ISCSI_ITT_MASK)); break; -- 2.25.1