From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452400; b=MQTkZDpH6IxPi9Huv3D7c+5JS+L1a6Tf8FO6OVC1YvH8YG32qYbxV6+/lwHtK27/cB4f TudkLV0JWOahiKpNApteMWo/nFOKBJBs6SYrDYoSf+Ui1T+g2MUThCIJECk57nbaspgkw uOv7XY50+qcbCciI63d/MNclTIcpSqCRlA7oM9NKdQavoplLEglu3It4F7K4vjqqvZ6na BFrxqNNRPSAHYeoKLNAFN50aeJ1ztrcN/yRQH7na4eSITtlKExyE5h93gwmyu/lH7OS6m tK5x/zuf8YsNRoHrOybBAvePkgcqZQrwv3v5998rCnGLOwqpod1lovfVTr3vaQFt7aQ== 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=u8rIrUgMQU3tzVB/NZpmWv1YDTDOHC4Fu6dRpd0BsVGhE3Lym7LHwvZmu627DIRrgH6F HQfPkbVDb+T4lah6qqhQgC4eILdZScA/budy7PVHniLD+vrBagMlJZ+0zSn+9rjIWGZNY +fA/jq/pOHFT3TqMsP7ePrTSd2WsXkjW4tjsS90Aj2VBuFvNsfPDQ9zlT6Im1tXfv5/RR ozV5Pbzb4M2Zug2r/uV6+5y4OxdSMhC9oEVm7LKZb/5n5tybT+Q50eZr3rIuDr6pt40Is R6TzScx3i46qLeb0giLxf2ofAuE79NgubXOPUUr3IHiF2Xc0Zq6r252WTEcqkUafZvw== 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.172 Received: from mail-dy1-f172.google.com (mail-dy1-f172.google.com [74.125.82.172]) (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 DFEC360A3806 for ; Sat, 5 Dec 2026 06:33:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DFEC360A3806 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-f172.google.com with SMTP id 5a478bee46e88-386c336eab8so3475130eec.0 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=e32UJL6vF/aTRSsjUo49Ulf2I+uz8foZmNmss7fOMbkMK8KHzTkThAwg/IN1diTiem CcG/xSUD3Fewyxs3EqOWmQ4af179t8fBK6K4iSWxBFfW1u8bb2u5pFrlv4NEKiEAsKon Kn1VhgAow3gBC5DJGWkfSpGTB2l8AzdYPbhjGzBKrduKwptxNDXRjfwfiF8DBjW3+/Do 5W8IaHXKTX0LRAtVG84H9AJFZwAQwEa7YEdGvADAh3mkOxI8KOa+fEFrRR7k2WFeKUHT lUmMvwTmwEwhc8E98EUMnvWbMjBB+LAEppFsDKop3ECNSswHWjVCKP+daaowaAeGrycH AluA== X-Forwarded-Encrypted: i=1; AL+hErEaiMLSnGaVa7d8fyE2EyNETkfNQOmnnMJa0nGfeKvAtvzaHyfYsMUZeQltzj7lZmwxzwzQb1cFumrYnNI=@vger.kernel.org X-Gm-Message-State: AB4q+uGUyKBSl0h06zjgBVk8vJHix5l+rHUeHibMg1VVG7JQ7s/xgWg4 tJLREJO+tUkeLlSOqFkt0qaWyKb6jt37I8ef23LduL9yIDSfH03NuXRm X-Gm-Gg: AZFdTZfDNBH2UbiMLZALE93LN1qbMNL4bPmdl/2IhwaY8Z4ie7Kf8RA48PbUdurpxdZ iopK2nzPVtOjfyvCKaH+e98/MxuJC5y33OJSYgKs2FwxlTSRba63rO8uSTPdxHmx19h/ckHC0QR z3cgwP1M4NH4MYuInLhMqOdVYPIjZnrS+VB7uRZnst4NpOzCWly106kIEfrjk3GuwYLw2eCSk9m Dn+ND/IRNtyqWmbroFxFuQIJWrr+J7BtvqfiqyZJGKCFiCpPCqsL1ANfE/3AskjJ/esnFaDrp+S Hpg3KJ5UdCgSsRU/DLRFHMnm6CUCJ55EtQ79nfc2241Qg4TDhWsCZ04sAim0M/lPfTAWEZPeMUF rqUr1+ypBRX/fcqX1UMhu9cVa9diuV467pD8eW7AYuKCLEYuvOKRwwDZQQLRSM9cRqO0H0nTnfj YNen9h6H2WPDHwZgtUdB/tdZR1mFD4FkJZp2VWuVndpbgeCWM4IRDelWoB0jkQ5B0DDjn+NttE3 XWq2/iqS5CQJ+1kBMDntezvgCW7kEa7Qip97CwK35r1KjJywwQ2H9CtvxSkmSdUjZSXjKTrMkHS hxH+QhFQnsuWbAAD1oNEV+r55Jo2ln4r5k0JLagBeGk77ufclp6IfOXgpPjZtqivBStcErsVpPi ncdGyvhe2tHpr 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-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 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