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=1796452400; b=DxSYGzSDY9sbr9n9G5d/j+EPeyvXWI1+/Kf4SDMjLr9B+r/sZ9fxb/4M6XGInBuLXIH0 Z795YwIbNp8vdD7n0HkJpWpacR1DqiH2EzRBGgjWxdj/k8FloVBT+y0CvdcTILdfpLAD4 MsaatWbsCuiDWJwMFV1eMX8WSKm8N206CM2eJNnheVKcfvHOBGkMekMki+4YmpDx5/pPw m+bjmhpJyd6x8DLUR8hywrhbuIQoU1Z8JCvljWeZfrjN+WRChQ4bx3rUU3KAw5xWUdJKj aqZf007gUxm9KArPux58M2X9IHwjAS80L9D97QMWza07cg7Jpvpvq3BOHzg+c0up/4g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796452400; 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=Em2vI0z0kiL86jzUU7H+HT1tPE6gEgVK4k28a7Fma8I=; b=kGhUk/AakJGBFXzm+aCKuB481WTu+qDi9nvabLUqwo84ozhhFln/FF+vTxOtXohqGAhg 5JvI3b/mDRc4LTyrRQRmhymmFh/9IFtzyRYdIOlAcPPqZX1tGtB6eDuRqreO94tsvw0V0 GFoflMWtXk3tIFttIjH/V2LHRiIUhPbYfIgB7Gak+uiGBAmOCZ22oiTRLz2JuhaeOr8mO NcfAlfUvdMTbzl5kcTpSVrQufV6BbjbHkkTbjMdhH9F/J9mFXEjmUNBZL3Dx4qLGNpq8+ 2zMfOHZunNdzHTDWPWIRcOIHs6cJzS54gUrRS4s0Mag8IC3ienlwrnRmeQ9idW932MA== 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=tJmCRd5o; 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 D86E160A2630 for ; Sat, 5 Dec 2026 06:33:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D86E160A2630 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=tJmCRd5o Received: by mail-dy1-f176.google.com with SMTP id 5a478bee46e88-3869f03af6aso2088546eec.1 for ; Fri, 04 Dec 2026 22:33:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796452399; x=1797057199; 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=Em2vI0z0kiL86jzUU7H+HT1tPE6gEgVK4k28a7Fma8I=; b=tJmCRd5oIJUB+i5kVMDdFfMzHEqZEaQFeXt51T9hnOmEXCcuwdqaPDOfrXfu2zRc88 ajtQhTTHjUGWo8oKF98M3n0jL2fb+op4D1dVCEgo8GXBxnQr6dNIuL3ZwW/vHTxhot9u RGGg1qmvc1ba2SK+r+dWCn/Dzjv/MagHXblbV1Dk9VMZa/BAWx6oF4rLgTeFW01CTLNq lUJZ4lH0iqI0kjARR6YGz7GPJTVnwCbo/akT9F4B+q1HqnmODUnJZ5Vd5F7lG2vGaBCS Ww6ZZTMj0F4jlbkYnK80LcCN/+VDFmcCzlqG/4TwFHrSlUG7q4O4JILuw3PfMMzs8st+ NJRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796452399; x=1797057199; 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=Em2vI0z0kiL86jzUU7H+HT1tPE6gEgVK4k28a7Fma8I=; b=BA/tQ9VwiIJA1fsFINgl63kA00Jha/wPNOJyWC9hZjQgLn1++1w0AhUIaQ8G8+oGqr SGKQE/d8hUj4bHXPtiMMy3EBh3T0R4aIFS4ylKrCPAxtcp+QNW7XgSm5HiIq2X09vAJi n6GxECkUkdnyzSMYXOc8iqm0DUYYUNfUOYBP4wEUdeTLVKbmM41vUkj6C/T5x17JNWC1 fuPNjosIapZbzeg5pIumbeELIxNLmcIYYg1uZR29Ch6M/eSM5jQibsxXULOuAWlT6Nz7 XyMV5gHZyENG3NIUfIqH5h0/YPtLb9sTvaCVeYUJLJ7MY5YOpGkmm8kQSbbFWbVvOErB GkCg== X-Forwarded-Encrypted: i=1; AL+hErGDCercyZ7ofqB5j2OKW7NhhEZFUn9vOY+cdVZAqAbPxO9X/R5Sj0xHnbh3E5czurZDUi+xb4p+5pZR@vger.kernel.org X-Gm-Message-State: AB4q+uEmu2t/nstsQM+QckHCXawlK4Ag5RsZymhFFECpK/gjejz1+82N 3HM1ur3yObIkLMEeE3R3UeeTh7tx9T9aPVj0S0VZEe0lyWYl4nhF9iEO X-Gm-Gg: AZFdTZeSnQzDxZKmW7EfTwSMrqfoSEtTyMB9oU61qgGCP/n7dtZpClWmzFW36HhxnmT TnU+fR1Iq/Ve8+Kl1bBJ4t5eNlrwQWqW+5FJJu7qcqX8oUCdpPbN+7vNEd24cOMBopLHNxluJdb VVWSxN0/alurGTegFwSD4bE651tjJHhkJWx8KB4zdgATn1+rXvJNaBfM0KNq9zBN7YaeCjaBx/D snTeTlpFg3jnFLfXqbJB84PNAwKehVJcsekp3kK8fZpjQfjkHmOfM7FUpQsZUkcPangqgukYQ7L bn84fH4cZ1btOb/lkdB6P4AOlRGh4f3ycFeuFEGEmOD+cfcrDiVFqcD52B8y2CiwDsUsbXu5XsC IRfje6HK9TcgDPBAnuxywkdUG9gJ2Rufvy87bDzbEjD+uPCe4vQ13IoqiiuuwGDmb89oumomR4F OUQTNjiBlLd9hkJYUYRQ2gVJpoHv4JD234A2LxcdHKD0zcIYmyzPbkAsmK/DdcUtrG4i95AkaE9 tgS5UjsjQRUOl0VZVRmwcRWaLqonG+v6ZTyEVUtycAA2MB25/Cu9ph+/xswer/zDlnP3wUCD6QP K8vjplNtJQqdqdNBeoKEo+WzUsyHUJcVvE0QwPTGCNchrz06X9xb0aaajo68zO49gk31kYZWihK ioktoO6lnQT0r X-Received: by 2002:a05:693c:65c8:b0:386:6c8e:b4f7 with SMTP id 5a478bee46e88-3875215c5bbmr3851853eec.12.1796452398681; Fri, 04 Dec 2026 22:33:18 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 22:33:18 -0800 (PST) From: Praneeth Balasubramanian To: Satish Kharat , Sesidhar Baddela , Karan Tilak Kumar , "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 7/9] scsi: fnic: Hold fnic_lock for the oxid calls in the FIP timer work Date: Fri, 4 Dec 2026 22:32:27 -0800 Message-Id: <20261205063229.2518424-8-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 fdls_alloc_oxid() and fdls_schedule_oxid_free() must be called with fnic->fnic_lock held. Both assert it with lockdep_assert_held(). The oxid bitmap and the oxid reclaim list they update are also changed by fdls_reclaim_oxid_handler() and by the frame receive path, which hold the lock. fnic_work_on_fip_timer() runs on fnic_fip_queue without the lock. On a FLOGI timeout it calls fdls_schedule_oxid_free(), and through fnic_fcoe_start_flogi() it calls fdls_alloc_oxid(). With lockdep enabled, both calls trigger the assertion. Without lockdep, the list_add can race with the list_del and kfree in the reclaim handler. Take fnic_lock around the two calls. The rest of the timer work is left as it is: fnic_vlan_discovery_timeout() takes the lock itself, and the frame send does not need it. This was found by an LLM-based audit that checks code against the rules stated in kernel comments. Fixes: 098585aa8aca ("scsi: fnic: Add and integrate support for FIP") 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, then checked against the source and partly rewritten 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/fnic/fip.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/scsi/fnic/fip.c b/drivers/scsi/fnic/fip.c index 8f44abfc01a5..e9d4fe9777ab 100644 --- a/drivers/scsi/fnic/fip.c +++ b/drivers/scsi/fnic/fip.c @@ -353,6 +353,7 @@ void fnic_fcoe_start_flogi(struct fnic *fnic) u64 flogi_tov; uint16_t oxid; uint16_t frame_size = sizeof(struct fip_flogi); + unsigned long flags; frame = fdls_alloc_frame(iport); if (frame == NULL) { @@ -406,8 +407,10 @@ void fnic_fcoe_start_flogi(struct fnic *fnic) memcpy(pflogi_req->eth.h_dest, iport->selected_fcf.fcf_mac, ETH_ALEN); + spin_lock_irqsave(&fnic->fnic_lock, flags); oxid = fdls_alloc_oxid(iport, FNIC_FRAME_TYPE_FABRIC_FLOGI, &iport->active_oxid_fabric_req); + spin_unlock_irqrestore(&fnic->fnic_lock, flags); if (oxid == FNIC_UNASSIGNED_OXID) { FNIC_FCS_DBG(KERN_INFO, fnic, "Failed to allocate OXID to send FIP FLOGI"); @@ -752,7 +755,11 @@ void fnic_work_on_fip_timer(struct work_struct *work) fnic_vlan_discovery_timeout(fnic); } } else if (iport->fip.state == FDLS_FIP_FLOGI_STARTED) { + unsigned long flags; + + spin_lock_irqsave(&fnic->fnic_lock, flags); fdls_schedule_oxid_free(iport, &iport->active_oxid_fabric_req); + spin_unlock_irqrestore(&fnic->fnic_lock, flags); FNIC_FIP_DBG(KERN_INFO, fnic, "FLOGI timeout\n"); if (iport->fip.flogi_retry < fnic->config.flogi_retries) -- 2.25.1