From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410164; b=ueKtHPcoSpvnftu0nATVowZ6h0h9Rqw62tYZNY2+VLQhDqFfz9P0oTBBy6f41Fef0FuL 0Nq6RoPYYSefwxWVU+dCHF1cK6WIimU33mZNYH5d8SdmOdvlqU1RyFBwpLoboBjeBBdGG JvylHRyPglvAETpcxRAZS5/mGlK52NJnaEzR3vyYxWUBhvy7NOhP+AHgMVhmYTGfwdTAF GgNdvN2dcR0zsvMXQ+j97REvxRNxPRTtaRPZehK2Jj2oHwtEppSvfOLN3TpQLBOETLVig SNYVauAg9bJy2CNOmPuS4hpP1Cy/8WmtBF9riMgeESXqaDWYcUU5JKvasB7VFIbPquA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796410164; 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:MIME-Version: Content-Transfer-Encoding; bh=zlOrfbz9rhbuNPXZDmQKQoceJdCJ6p0PrlFjJX4Xdq0=; b=ZZ/1vwowdbADZLHJT5HGnMvA5P2x8I5vc5sBwbf8sCWxb9Xsi4hqChG/3lHu2ixrmb0h 36n/X7H4HbArFH3dw0hcR6JjA2vcQi0TcS/+u+qCcCXcyB1fN20cndpib2pl9iNNmd+PM 8r774X8rxF9hTl08pv03IkBvOfoxXkcvC8pcSQSG5WqWuGUIOFqq/sd8VdB7ulIxVWgbr lyhNox6p178wl+Fc8xqRFRPchnRD/6kA6gHeStH8FvxBbEW8sozt6uAg0CS6TqjJvzCSX 9PtFNaAV3qPZ1fvtzd2JRwcJUSZd8MBakQut6uouF740UwKvN4YROndy6Mn0oIucbXg== 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=FGb2eqys; arc=none smtp.remote-ip=74.125.82.43 Received: from mail-dl1-f43.google.com (mail-dl1-f43.google.com [74.125.82.43]) (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 F3F31606A32C for ; Fri, 4 Dec 2026 18:49:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F3F31606A32C 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=FGb2eqys Received: by mail-dl1-f43.google.com with SMTP id a92af1059eb24-1b5d60183f9so1475354c88.1 for ; Fri, 04 Dec 2026 10:49:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796410163; x=1797014963; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=zlOrfbz9rhbuNPXZDmQKQoceJdCJ6p0PrlFjJX4Xdq0=; b=FGb2eqysZk2S4nqCw9SS2vuBvdHIJJQmJB+RuVVnkq7L44I2VD/VZ9ZYspBdw7Cd66 85k6nE6jUMYrOfbu/5WV/WL66vGXcS6RS7V1qEYihyKRDRvhRhNuzutf/ULdM2a2Iqou nnZAkaZTFHUFL8mjo1y74lVWTKzBzdb16pXDa0ZhAEAqXxbKBe1GmbKuUp/s49w0R16T 9/9laW+ICiIotQnLEqK05xap+8jUCXnmwjXdJSe5S2ivofFe68ujmiPG9B5wFaRpY3FM sL+EPlnO/AJkJPV6X4OMDa6JbQp0HaiVs0ocFh9qJmvZF6xCMKjm/rJBynAlz9wG/zjf uqew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796410163; x=1797014963; h=content-transfer-encoding:mime-version: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=zlOrfbz9rhbuNPXZDmQKQoceJdCJ6p0PrlFjJX4Xdq0=; b=dRbv72o9TocTnnPhoq+l3kh9R3yvbgnCirC9icaCm7ImwEtyJZ+UIzoCKQ2TCD4usO +cgDCHs+lf/wo/J3ub4nUGz1UNyoJPJzuJHRwriIU7JrMTk+3Ds4lE42o3PGMHQB9OkH bXDnif1vgEDk4owQ+coBDP8mw8K3m0eK23DK2x0AnaAQ6G6Uzq8ib/iskCYgzt3YyT+F 79z0A5/7sLXco0crLhvE6eR1QKDuRrukCGx7lIn7jk0suwk5/aIbERKgv9cY2fqLuXQ4 x53gwjuu+8lWnsbD6t+XPujgm1d8n/0gvpQdLJWeWjomzu7KXh3PZfICCFlc9AFMpqGG EaNQ== X-Forwarded-Encrypted: i=1; AL+hErErCvFKQtIADaIjt5ORMyI5hctlkKIZKp+iSvND1le6f5G61rq767T67gbrF84qM500/x5S9sM=@vger.kernel.org X-Gm-Message-State: APuU4Z+LbfBTqRsXM9snUApDbjun+zRCw7ofAlLl2OiAiC0vwGZ2l2tk p9vGZh1nkBsyyUIiNmm5h6PItV5uOU0GYP+sHVIHCVjvzvAoJi8Sfj9x X-Gm-Gg: AZFdTZfHLLwKyOkWa7ORi69ihXXZdiJamLgLELq3vuqUG9JA0+pLFfrPmblHKCbS2WB jIcnb2aWkqsDdwxsJrBXhvJeH/BcKFK81T5Jp+D9k9HeXIYnF6DvgesSuydCkq4kYWHaxGxnPDz OXq8UkcfumXlYMrUIQpX2rtgOivALXRXtUD1UMASn0OrDL3ce5vSJdFwcfkOlv0mT8oaf7fPnbT 03H41MYO1KcyLdLc3G/Skg9czZeRr5I8zWqWQVYVqHao0iNuXJs46hMdJAHXikG+4nt2jkIww20 9yUBak2uKxWOctpNd6JdIkytkJrDl5SgkU5yUobF7/+tjdqIVevE8QXk0PKyF5cKwsrrjc6+ld8 gB8bYXDNGNxiCKd69z+op/xXXSon2CXrfitYnQP9pwoFd6xAyqQdSplZbgesMGllENNcAUUpc1o 4UVlffUvjhIm4SiUHQnUK1IfEf/uEhiB6zfU+eYCaVYi1u8JHxwfZmCCh8OLP53RpjioAxcWkb6 SyjC0OumgLOEc3M1yvfyuEXW2EspUMeO4uE0fxMbKyDFgWVhOzZEYR83KYP02gAVol5N8b/FPEV LFZ2wri2JCamSooZwza8PL2e3La9LhiooAxmQusPR3wy7mMxBh2Vql+EGSNsCMhHtHo+iUx4VS8 ZW31oS16rvtUF X-Received: by 2002:a05:7023:e58:10b0:1b5:31e4:9970 with SMTP id a92af1059eb24-1b5d70fb6c5mr2396354c88.8.1796410163112; Fri, 04 Dec 2026 10:49:23 -0800 (PST) Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d646217esm8075277c88.11.2026.12.04.10.49.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 10:49:22 -0800 (PST) From: Praneeth Balasubramanian To: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Ranjan Kumar Cc: "Martin K . Petersen" , "James E . J . Bottomley" , Bhaktipriya Shridhar , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Praneeth Balasubramanian , stable@vger.kernel.org Subject: [PATCH] scsi: mptfusion: Handle firmware events one at a time again Date: Fri, 4 Dec 2026 10:49:15 -0800 Message-Id: <20261204184915.1686726-1-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 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 mptsas handles firmware events, such as device hot plug and expander status changes, as work items on ioc->fw_event_q. The SAS topology code relies on these handlers running one at a time. For example, mptsas_hotplug_work() looks up an expander's port_info with mptsas_find_portinfo_by_handle() without sas_topology_mutex, although the comment above that function says the mutex must be held, and then passes it to mptsas_expander_refresh(). mptsas_expander_delete(), run for an expander "not responding" event, unlinks and frees the same port_info, also without the mutex. The queue used to be single threaded. Commit b2990536f447 ("scsi: mpt: Remove deprecated create_singlethread_workqueue") made it an unordered workqueue, reasoning that only a single work item is queued on it. But mptsas queues a separate work item for every firmware event. Since that change, two events can be handled at the same time, and a hot plug event can use a port_info that an expander removal event has just freed. Use an ordered workqueue again, so firmware events are handled one at a time as the topology code expects. An ordered workqueue is unbound, so WQ_PERCPU is dropped. The unlocked lookup was found by a static check that turns the locking rule in a function's comment into a Clang context-analysis requirement on its callers. Fixes: b2990536f447 ("scsi: mpt: Remove deprecated create_singlethread_workqueue") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: This was found by a compiler-based check, part of research at UCSB SecLab. The locking rule stated in the kernel-doc comment of the called function was turned into a Clang context-analysis requirement (__must_hold) on that function, and Clang 23 with CONFIG_WARN_CONTEXT_ANALYSIS then checked every caller. An LLM was used only to turn the comment into a machine-readable rule; the report itself comes from the compiler. The patch and changelog were drafted with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64, clang 23, allmodconfig). Not runtime-tested; I do not have this hardware, and I have not observed the race myself. drivers/message/fusion/mptbase.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index 3a431ffd3e2e..f6814c465175 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c @@ -1985,9 +1985,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) INIT_LIST_HEAD(&ioc->fw_event_list); spin_lock_init(&ioc->fw_event_lock); - ioc->fw_event_q = alloc_workqueue("mpt/%d", - WQ_MEM_RECLAIM | WQ_PERCPU, 0, - ioc->id); + ioc->fw_event_q = alloc_ordered_workqueue("mpt/%d", WQ_MEM_RECLAIM, + ioc->id); if (!ioc->fw_event_q) { printk(MYIOC_s_ERR_FMT "Insufficient memory to add adapter!\n", ioc->name); -- 2.25.1