From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.176 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452399; b=HzQ8Uk40rq454r3KAxCVvVmePTPiVO+gB3Dy+NfpkYxq81Qpo5Fsqq+7p1UxC6TbEXlY FSp85i8CyvpMWl9gxTbMma501dsccR19jdibmWIo7p7hFDmcbQFd1UQbf9wJ6EYxVzMzv ytWAf8dhfNeEK+sLP+n2A1CxjfBlhqDKw/2Aoo6t4Cn8iQ6bB+z76S8ItSbPXexkdtJHJ z92K88Efwz5L4SfWmgwxxCPF93b+jXK6zQWO2JuXAenr2KSXlX0AUVAUTpI1O5xUZ7+sH 0yTjVihsfdJNOjRdyk5yRA9pHppi4vRv8qLDGhfRJIrt0gnn0NZ9WVo4bgE291fIo9A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796452399; 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=4aO5NONlxPHWQG+zibdiLRcjAByXja9DmKGyDx3gOHA=; b=FCn0QVThcEJWyUsDzishZOHb/6oFi2Z6B1f7Pb5Roz4AZ2KVSHkfhk3ckmwYQhbvOtFU nyGImuOX4o5W8yMVNe3rYi14kcuK3v4WaajVlDU7BmO/L5+AKaZdURT3Uq2Gt7M/TWN2s sev8TYE/uiiQUHNPA4i1vP/KCgpldrevRnajjkbcm2+pOjc934ymJ4sxgKgfyde90w+OQ iSNuwi6sFCmvy9dQn/0VhSN2GxI1QnZYPIWcMIZ2MTnjlhodUlpIwfMCi6ms3MHlQKYYV w7+tSbyPm0u4dQ+2rdKrIebAoGV/ng5K/tau0CYpKlLaYmX7KDCKQ3WOX8r8mKKXXIA== 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=oO4ZsjAz; arc=none smtp.remote-ip=74.125.82.176 Received: from mail-dy1-f176.google.com (mail-dy1-f176.google.com [74.125.82.176]) (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 B3E2160A262F for ; Sat, 5 Dec 2026 06:33:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B3E2160A262F 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=oO4ZsjAz Received: by mail-dy1-f176.google.com with SMTP id 5a478bee46e88-38747f42472so2768680eec.0 for ; Fri, 04 Dec 2026 22:33:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796452398; x=1797057198; 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=4aO5NONlxPHWQG+zibdiLRcjAByXja9DmKGyDx3gOHA=; b=oO4ZsjAz73MXYwg8N2pRCM1o2XLulJnHdkqCaQ5djZVuQnOu7qusE0El0gKU1WThy8 hj6tNM2hwO/A7FNeP2fLGB/DER1dpxOmSBRDVwyrTDic0Mwwspjb6gHAhXXcmsZp38hf gV9QYmLLESh9tq2dCC3Uk+bgrvSRPazu1PqxPkOJOmLexGYXnMowqRbOyGbf2Pa+XCd7 Cbq96NVnZQQJaKkTREZHJ7KN08ymOj2HZoODLDJGoVYj5PySkRyKT7HqiKNg+8jfYYpD Qoz+bcFJwG53+CANCxmV2usz3EpyrzsU3Lo5w5BPXkAWXAodUVRAM1vZU77wP8VAB92L M3Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796452398; x=1797057198; 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=4aO5NONlxPHWQG+zibdiLRcjAByXja9DmKGyDx3gOHA=; b=BB15J9m4uHDUo+f1S0EhgjP4q4DgIU9XhZFMj0qNQOzj0yHuxKZfnc+y92zzSfONBk jDE8uqjBhqndf8s92zfdXLNlRqP6mxX1Sbk9Lcre0r0/RnkRpCBiANwT+YeqqYHNLB5r m4Rax/HM4f7iG6WwfpXK5xgsBq8iFYjT/s5oHV8ey0uc3j1M8iQG00guNftkfdaFBARy QRJF8+7cQMfjBE6dyRwGIZbrkjd7ApqbrWmJciEku8vwkBXxpT4vs+xEo4Swe3JI8xsX WKJv1bbimfS3eVNUqMBVQYBu/i09z9Sjzx8USGJ177Gjqazfiptx0TwEBnmdO6bDOXPn Q6Hw== X-Forwarded-Encrypted: i=1; AL+hErFZAyQMwzFR36+bgh8GzweqjKTE6cBPR2Ec0l4v0dN24LKtyBzwUd8KfeX69eK1SoZa9gd6pkhSwq7fFqA=@vger.kernel.org X-Gm-Message-State: AB4q+uEB25miYUvsFgQKi8ek51XMMpKfKCE3QVPMY6qRoB96RtafOroB Hd+K8UAHnjD7svDr/i3siQcsEOGPtesnL62z9Uxuq1LFxUzXf0j83z4w X-Gm-Gg: AZFdTZfz1qnvpZC6O9kgo0rAsjcZVlGmjmK5PAnC2Sar8cj1Egz7uHb++jDO3Ngvz67 FIRMuyz5mBzeS+vBkSgQ2anp7UevgrxULO67jjYFSbsOqA5dKuFzSOmb6fzoCcmrU6u1qubACKG +dDQ0Im+hm6Qc4EYFAyG9X50Q+V/vfUo0qSpBV3rcBKKh8ABavfkmZiUMxfGZBTde9TnBLpTQg0 HKjUHpWcvTsRT20YieuJmOejcCrSVjW+B+ou9zDSD1t2BxKg//gMUB8TklH1wywaIMn8LTsKbFu mNgZnEBCFKbLL144lGe1dpS0TJo0IzIEzbo9tKrevPVg10T+1sdEBgHir7IWBiQrHEL61fZ1o8X R60YWKnwmar28Zu1i+debMmrpBQrm1aeRqQa6tgjUlXPAgboZtAzPBfOapDPjqMWe3Z8ZPI3LFb qdVfSu16JAhJf8tboL8mBKe6T4TRXrXL7+i6hD9FiQ1RNNvvqp3zEMPmMHrpTVNyx5gxXbeAyZD tePh4IOAMc+/C7JDxhlnFIUGwbyiKrVaaQlrLnaBJuPDHzD5kz3V1eDGR5br/tHCnIboAzZCgyj TpQ5Q5Hgc2D7A29spUWJvCKCqVDzhihC8lrc5aZPUEuo/ZMBcG9Y3fem29E/sV9gzGoQYiipUJa HTMyo1uDzgPxj X-Received: by 2002:a05:693c:881b:10b0:381:6ac8:ef2e with SMTP id 5a478bee46e88-3875219ff2fmr4175506eec.25.1796452397883; Fri, 04 Dec 2026 22:33:17 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 22:33:17 -0800 (PST) From: Praneeth Balasubramanian To: "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 6/9] scsi: csiostor: hold hw lock when issuing port stats mailbox command Date: Fri, 4 Dec 2026 22:32:26 -0800 Message-Id: <20261205063229.2518424-7-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 csio_get_phy_port_stats() calls csio_mb_issue() without holding hw->lock. The comment above csio_mb_issue() says that the caller should hold the hw lock, and the other mailbox users in the driver do. If another thread uses the mailbox at the same time, the two commands can interfere with each other. The path is reached through csio_get_stats() from the fc_host statistics attributes in sysfs, which every user can read. Take hw->lock around the csio_mb_issue() call in csio_get_phy_port_stats(). This matches the locking of the other sysfs handlers in csio_attr.c. csio_mb_issue() polls with mdelay() instead of sleeping, so it is safe to call under spin_lock_irq(). This was found by an LLM-based audit that checks code against the rules stated in kernel comments. Fixes: a3667aaed569 ("[SCSI] csiostor: Chelsio FCoE offload driver") 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. drivers/scsi/csiostor/csio_lnode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/csiostor/csio_lnode.c b/drivers/scsi/csiostor/csio_lnode.c index 161973957976..7fef0882862f 100644 --- a/drivers/scsi/csiostor/csio_lnode.c +++ b/drivers/scsi/csiostor/csio_lnode.c @@ -1408,11 +1408,14 @@ csio_get_phy_port_stats(struct csio_hw *hw, uint8_t portid, portparams.nstats = 4; csio_fcoe_read_portparams_init_mb(hw, mbp, CSIO_MB_DEFAULT_TMO, &portparams, NULL); + spin_lock_irq(&hw->lock); if (csio_mb_issue(hw, mbp)) { csio_err(hw, "Issue of FCoE port params failed!\n"); mempool_free(mbp, hw->mb_mempool); + spin_unlock_irq(&hw->lock); return -EINVAL; } + spin_unlock_irq(&hw->lock); csio_mb_process_portparams_rsp(hw, mbp, &retval, &portparams, port_stats); } -- 2.25.1