From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452399; b=HRMTsp0EOOARKLXsMEdYjg7ibk20GgdlF9jXWKEzkP4VEdrITHHWRYEKzAhDZz6K/s0n xLzifZ08tm0IkEW+m15KRcT5IrqQZ5STFcBnWwz+iuSFaKx3ELpCHbb/i/iWQt27ipnOq n+UlY7w8Sg5rG3OeNzY6APsaWOoDg15C+i0Wb5OMZrIu2xHx4bjIh9u0P4OeFA0cRzWci S3GuWg3POEh4pG6RWKiERLDy50PrhtZfv8O4JZ3GP85w0WAMc7Ro5+HVFcYNQtlJDi1wL 6G4MNZlrpP/hJUGSjAtBWyrWT0tqE2NV66qHv6Az1HbZgNS+eBw0vEyx+O5ATEkP1xQ== 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=yXo0Iz5g007SjUtEiZWSSlngrMDtpPJHDLhmkiuuWL8jlyxtAIAPfF5L7N1hqGBJwuzC 9+l4FcjmVwf6k6JXIetru7FJ+6cKb+3FBcs4IKekpk5/F2wB6e3yfwL3HjfKIS3/Mdyix A6Samgu7M5eKhJ1r2E3iyBP1JOnqQDgajHTMlFw5YeBu27A0qpRhDamJvWXaqqxkAE6hA abv80BeNS8opGXN1XaNikcTN+x3+9ERKlqlPkFKBp9vS9Rpo2Go+VxeZrQnRHGCVENVBj v+USeecwWNyN9hR41iF0i6Qk0QQ8VPm/eAZrDntQ68gkUJojz+YMWo8NJPj212J6pQw== 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.175 Received: from mail-dy1-f175.google.com (mail-dy1-f175.google.com [74.125.82.175]) (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 B117860A262E for ; Sat, 5 Dec 2026 06:33:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B117860A262E 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-f175.google.com with SMTP id 5a478bee46e88-38747f42472so2768681eec.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=bt6hcRNISJ9bnfJ1wMn2gBDtf4yaWk14oUlR8uizwuB6u5iQ036tgDW7bJBLdHYadl ZBkdyebyj6bf49BC4Tx2V+7mWydFEtX2t3Be4gyx3iboc+TVB8R01hTATPZmpEag9rqT b4csf73KT/nY+aii8CEetj537L5H+oYYrZOS6/qsL2v4PyDClrJnUY0LWLTDoFbE6g60 7uYnfjIrC9cuLekjhAGJDleguVh3FVg+tx75lASvHL4XAQHSJg/89KoQHeqSx7fuge5f tvVGOfupQjykwviQ8Ix8Ie7Ssx9myhCuXVgyVJ/5y5k9zAcIstC+2XKLzLx1e7JL+JyW oMEw== X-Forwarded-Encrypted: i=1; AL+hErFKhHRcnqp7gAWOHtG22WJxOpWPHrw6V0RKov9QG8pKDqjOTN0k9ADSVuA+6kF3aGj4vPwWmY4=@vger.kernel.org X-Gm-Message-State: AB4q+uE4LzJ7ml02+OmMyLBFpMyvxxrPkim1/WWaeIKZ0DO2GT69/Sb1 CRIU0SMX9uWm0ozF4IMkz+WDi+y4SLLas7IrcZ1+JH7YqvwK03Y7+InQMan9BxY/ X-Gm-Gg: AZFdTZcdPNA4MLVW6X2KubNyLFGTd49Kcn3PqPS+mGeWOL+EdD6xbRc1kC+INIEL73V czBDkBZUId0gCfRFX8Hyx8DJji6dHLM0Whe77JDR46or/i3sM88ynrYvQLW9isxHj6Tieq+4e1U qPLUTiu6WLPTr8Zszk8hZ1NtUWDFJryDzSPSb7610mu5tMOaYlJmSOB2HXg2VUSXfZcYQ5QjPUa hmI1V78ee8eUQ8Inq/OH7wQ7pTxSzvaZ/v2XjG1aRmOf2K4646CKzitURmioi76eMnMB+j3kREo AcFiJRfM+jwyl2Vy24rni/hBO0qEoKgIfBzyCINGfeeCDj4UyeTwc9ZiuhoPDnlB9jWmzsfo4L7 RTS8mbDBPuYjEYNQsxd67wIDSiNMwEnC6dUW/soBTP2gKCCsCh7amFEYcPSA7iWwClkBHc5WGZv HmhkU1ScZdmwcqhh4VWd9S1oIfp7Nq2rBU5LydCsnU24LpknvgKCYS/ky8jBihKV9J8zNnFF0WE PLOb6gi2bYcPqWUM4dXZGGeDyaZ7DtJidqAjvcLId5eYjafF5EOSJbuM4hyzpvtU1sofpD5x+I4 CzS8GjSsNsABMc7J4+7aryXFdTpPUOfVJFm0ZA7zyb7tryfXPYWNXfa2POs08pMEViQrjd98UCA qrgJ7XQGTX4+7 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: 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 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