From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452395; b=tMSfbQa+MdBP/u1HxP59GSsBtMfJi0uRcMkGtWDJbk66/vJIu4kLaSCoozlxK8bsp15V zRugGf4HRThEbtO/M1jPsPGHd5vTLiExD/a6poYFleaZnGnGCT+qaTLw6kL3YCXXu3HAI Sy5E4Cor4gPYMnAzk8G7TH/RKl9moRo6ia8azC+ycxVkRfTlCG3x+Q/o0eDPgRTv3kC6q 70sYWSd193dEOz6EUdU90ApL8xaQ8gnwZ5VNgDaNoDCfGOS/fPVf7RLSKEOtZp3I/C/R/ bauxWnYszA+eqFNbOnhs/ATIm2IC2+rOupIAmtHNVw+0rr5g+5ZrYqqyK7vvgChfUuQ== 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=fGlj0i8gYvsy+l+zd0rlG/3iCvcLT1pahi94p19sdesLxcmhP75souMd7K7WC/rEcj6H EsIZOecOT859zQ/bg6y/zfWP61M8920Gc1BvwYqXZHBOEI/+KKXGoCRaT/PWdK6s2iD5w N626KOtaPGYIHHHsSmVtFA/O9uZO6czv64K27gzkYCn8iO3rr+YOHG/DIZB3FXv+NOFo0 dTEASVZrAO/sYuk5NwyVpuEc0CK7boaoiVA3C5sOfpg+aVzmvOXIMZqQAer/JqpbpfWi6 S99G+0ENZg4rQz3xxCgxo4WPGcs2nDRqtQ2UIlXhvSERhbnbfrnB8qUrwRN/wUuTi7w== 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.52 Received: from mail-dl1-f52.google.com (mail-dl1-f52.google.com [74.125.82.52]) (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 A910F606A335 for ; Sat, 5 Dec 2026 06:33:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A910F606A335 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-f52.google.com with SMTP id a92af1059eb24-1b5d60183f9so2080398c88.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=ZPtZn816vhjh808KHCElxvLz5vCe0eC68yiPcuQQ/xA/6iw11HhqEbQb03rRBbWtd9 C8qHJ0wr67GhZH7QVNugoWExQcl/W8o5IIXdAncAFZhme94VwOlfirWVm3z51oZRcTnE DxjEaNQmwKR5zBn6ytKQqqGdeHVd6F3oIrh9k0BiiELFVfFha8I11mYWJNgdIyRYjQpB rRx0awZGXiAlwwLoCB0/2NzU83HxFk8ESa+YHXrrnzzdZ697b5NngoEkvoRYWFLN42Yv FBx9mGGMzlupPAkdf6NkBCowZjCoZdVwPdl5V9zE1B9i8XzZIL1y4XlRVxSKEbB8tl0n 5Obg== X-Forwarded-Encrypted: i=1; AL+hErHYd6xBSfhOMC5l37IexTjDy7yBzROJrqJyI085SsYM0+Hhe9RKO96HRryx27PEaNxqeNB4dEuN10wX@vger.kernel.org X-Gm-Message-State: APuU4Z/2LHxv+GleOqccEcNPyxKttIyKRX0QE2T3SslvuE0Z1/XhOsGB xhoRfQP7Gr7+OsHUIQaMGaeGQtEPMGxt5cX+Pc5hKuCRZQ0K81Q8T/Nm X-Gm-Gg: AZFdTZfOJ0E6Jl2rva1+9oX+wLcYA/CU4M5l46pl0NCKvT6pAT3YMps3ArTMm6Cby5k 90clQG5Ylea7fRXwamAoPzL/05HNRKOZymX5Ndc1or8morthOzh+AIq/8mx8tnS/aF+hq1kV0DS 3U40beIhNRZo8f9E6qMI3L6tChKHVC0OdszaRjltQ2uPYiXFcdTX8AhUIZRJCnYc6MAgiEL8tDd KBHx0fU3VKSvRnaWkws1On4HfYVa12YTiDZ3eDfM51gGu2uWcRRrZ6LH8CgIVsrwXC1Xzqh2qUM foDt53TkVarHOHpLRBQ6JS2xqg3TTSxIvrtPAv9yZUmpenXbmZA9gmF0Jv4PC6Fgej7fXvFG4ZV TyI5kPCGw+pnq/50k9iMQLxK9xdujIOJaq9J97XQ5w2XGD7B3P6UiYif3YxCLqSVYPtEoCVMtG8 5Bk2CwdBtwmZMQbMI7I/lyw9lteddG8/v+NNHFmfyJZK5ngUcOb8g6dOq3LnR8DBLVyHHMkMkmB g8VBQK6CF74ypUEVwXvKcmui8Duze3KYTGfFo8M+irocUURq7Z49NS03ckTP575xncg7KqMH+Fg ojSs9qCVdrZeBG7QLNNYvptA4rl6n+aextxzrwOP/uLAv/46ZwFJBuUUoCC+fjHPWbg= 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-scsi@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