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=VDuVvFutg9x2s9bluW0MPk3AqDKcsRlAtCgnas5lKPDFK1cRs/MEnp9SvHgsPmp6EvjX CPToYHmwfCqS9SkUT+o2z3F6kBP4nUzyaGUF2rep0YdADqzcJNaqKZIWr8VR4rmWgttPc KeMgRr7vyGZAB3TDTO5cxmOrHnZntqQ2hODdTHEHBKWb4qgCA/gfmKf1D7D/guoPYApgj UMobrh1x1xVCGfqGdtR23cKkcbT69BX4+vmQXxvjo9hc6exUwWKzRJTbAyelY+ZXsJx/U 1mpS7qPKVYgvWM/wMbnicgaQJZAunc/IYRzMv4w/9M0DGSLQGjNoLHwGIWtvZHzwS9A== 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=19NtrNxPGSjc4iogq+KUdybEzXQNzaNslA8VFiKwb1+V27C+dFj66An7NBIR4MTWfr5o 9418r7P7ImWlwfmU8aDRdIPVlFUcMhbgFlbDtyNptC9PM/bGeO+Woos1PFdjpiuLZ6FeL l4I9Cbp2cI2h5oOyej4D4ioUYLHSu5HAbsrOthLnhSWoOh3yLrDN1nio/gpjICwyyQTKn 0l4MTE6D/YV3kUlSOTE228t11wMiY+cGzN8PQLeqs0wUgFiGuz2DPmXI3AnRYD/9rR9lX qmvT6DIBf7zIJ4zTrZzyKAZvhCsKv2Y7PSnBzEq1KiK7KmTKsLSO8K82oFOEUBCkr/w== 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 C2C0A606A33A for ; Sat, 5 Dec 2026 06:33:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C2C0A606A33A 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-1b5d5f3d5b8so1766597c88.0 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=xSG/MyK652jqq7Bh36iHtsfvhzwI3U46IfujSNgiKK5WEbaQGtDQJH5BDQU8bs5/0W IdpLomxsoLIDXvSA9jWpyxluL7tZmrBJnY8dfU8CZ/8b7jGpA0StQSMR2VSUXuSm3Pf3 7Asf1dm3gU8t/vaah8yBak3g36NhIOru5mCQSlyHAsLFmrWpFVQjbnRJKndBdUKEM5Ne XVD5EcBKaTPzC7h0kLEq0zWqachKfYwgUXzS63ojDFS59b3rKWYWG/GydJB7/5tuh6WB JtbmZ+sM8UDUXSQGtp3mGmNuCEm/feKr8z0gTbEA1f33YiuLELLM9oJgt+/A0R9vv3DI sg+Q== X-Forwarded-Encrypted: i=1; AL+hErFF/bDjzmNF9EoHV/5UjNFx6/h0EL0jWGKLKVG1+vlzV94qI/P6Bx9yG0bX1/UfLfEYeNImsog=@vger.kernel.org X-Gm-Message-State: APuU4Z/dq56IwHl++AoIvDpc0Vpyp+6aZjlKrDjfC5AfViOgCSVm0w1X AOBTvRH0yp1+46z+bw0ArvQz2s/F2qSJcg2vsrF94xAG6DXaXOzs5PyU X-Gm-Gg: AZFdTZeUQ95ZoJpICqXDh5+WVVkJuRh4/cjvaVzUnw38/74iGO1zUfrrbZIdlt+jJqC paOOfvT142bo0iTFVhLh1owFRAADZsWncMruXMJB4yrx0NDl8jcZZRoDKkYE8PlGApYTtZjCoC2 mjUbuirTYCWdE3RfXvGK+FgW7b+5UZQRxT3odM/GPmKevmnrG581zi5f6wK91J1y9FJ+Wau8iZG wBqyjOi0Sn5xren7F+1+mBqUpBM/+xDiX+2eP7rsb26J4+H1PTCUTSBG1m3LNMGSMqXZTkUY8/M J5ljVsfHYpbi7tetj+vfXhqRG8y5fYwlTCspZUaXGd87pkNKISJq/6xl5uFQKZ5I3xhXu9X39Kt Vzxb6IJgEywFOL/+CvwD1QLu5+fvuqRJbYH3wUWy4H9ti+JdyHdOGdbdN7mHhpcgVfCx1tH3EQw j5Es2sch8/fkYsK7h4hiNR8lmUicUAtQa3FHHWoreomR7g9DxcYWVbf08p10ME/gujHslBULvJ6 peu+I+DJxST4L0HBE04MKVwi33F+G6TSePKdUY0LAFrDSBrU/8RaKttN1Tuz/OryT9i37+ZbV2z wf7GuYdZaoWMXjTP7rjhDsUj5s4tOe2u4x+gEZ9pFO8T7JW9m/Ns/neLmziymRO+jPg= 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: stable@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