From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452400; b=YMKbBQTpoNuCLRQsZTTJhdcQ/ops8o8faGPlpdFLR+XOAecYV8K0OggKRLlqBAyhHkKU +Fk+8UGMqsBRQEVwWdlp6Q69WBM50FDlvQ/f/39cMn3nCDFOEJRbXdj+I59AmntZXW2cy wZ87mg6DJ6TImoo2s0yLQ2L+fCO39jbhBAN3W31JeUBCyyWm0KvUMz6aP91QWNhMP85Wn JGyDY6DnMUifzVw9jWlM5BNoy7nl1kQr2SCHHettQApoczlafqcSwyEJ0sLpF54obFxfD Y8Sa+eIqXloqVkjKggyE4NuSyZHwyFj1h1iYzq6HcBg3s5KgX1jE6J0O1wFId2UQZSA== 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=BdSJUyGK3GBsPVLwJ0LezPJBZVpLcS4VF5KvltUTdVR8nixUT+esKKCyojBYqlarZnHV 7SmGrq87NUvAVb9fFnlTWXjMMRbHzV6X3YJHtU7xV5nJs48XXMxz+JcMeN2yg3xNE+I8z tM23iyCFF6IrRdVzwOPx1+jJ9JYuSUyv9ROKw9iLVbN4mGbm945u6jeZsc2FQJyj/hk7b /xYI7GuQcPzKzXK0BCfsz8bNo/KPOZFGy54/wZyl0vzxEuv6tfkmo5kymCUvn0iadgdZL u7DjrYEsoQktmtqhDlcD5/F3IULh4GWJl3SPHdIBrGD+8NvRZRRMHvYSL5dB27fELOQ== 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.173 Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173]) (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 F35B260A3807 for ; Sat, 5 Dec 2026 06:33:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F35B260A3807 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-f173.google.com with SMTP id 5a478bee46e88-386c336eab8so3475131eec.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=H7VFDEvml4N4bLpy/k7ia5U5C3sjHD9TlXdv6/mjRItRF0gyMDDQ0lY0GUvlRID34k elhoGMcogbZhRRiKDTcBoVxAmlFUoVpULs6GtD6l8g33Y3JJJQHqLGfIe69R8BbP5FF4 ZOOEDzM5lGzdOS62fuw66F8LwyIPNLS1aVKbI3BXG1+YPLuIlvFvJe8041O/w/0UwsNr TJLXmxj6ysOd1jpnUm+448UGRiSdQqOrGip/F5Z4YFAVC+106/iL4byRYWIbQWvGf0Zt TDKAlo7PBE9Gywd4ql7+cZ43vIr/4RYvnixRicEiN3GYixd1Y1GB7WuaFQKulxD8fD7k rwug== X-Forwarded-Encrypted: i=1; AL+hErHb5bCe/fvn1slL37TjJQM3EzkOyD26M6ZIZtKgh7vCDqBnf3cBbRwa3w9+tsenqRI0I1EmoeY=@vger.kernel.org X-Gm-Message-State: AB4q+uE2d0rF+fV+fOGzaU8BQcXD1vBNAoBwmBSVZzwLwptc8oBZ+Ykd vwyDC3+xHRR8RR3wyw4x5VN3yLdJXVVf+OyftCYOtaNU8dq+VHJ0QrkF X-Gm-Gg: AZFdTZfQFoNCL5hRys6qd2XSZx3ilvVN+A8rXIa1IKnSaLW3HOTW0mtXl5CH+3kz3WZ RHNVtEZ63nxxo0Cyhp7Chh9szr+LTzDnAIimju7vn+2DmXPeXxG6kVPrB0FYQ7EY5L9AiAn5mss lJH61m630wWziP4uTvRH1tid9grIv7r19oeu5QTE/UYhEjk8moHxCeaW9aTQ8gm/jGj2995oh+M vwrfColnUYp5QzHjGCTmGnV84PulFBrZSyxXaDyc5Ll016kdME4wFl9fuwgq/JVb1Ek33quFX8Q tQvcQk9HlCQJyZf90DuBZBTRjPpQwFSBMOevb3JwOWNgmTYkjjPnce3mG44TvIvpoLALQF9q+k4 NHQ47BBHiDOT7yyB6Fxd+PpJ/6n/12EbwOW8gbZNi2jzNdN/yNMNS6Tpq24jGcLda4DCsIvRYns QB9TtLGAM6m3ozESkiSSdw/kTzYpj6fT/ObKl4ygM06z/HSp62M5knYcax+2faj31Btp+0Usp2Y 2t81PxEgzYBVGb5hNGbcHWui6OkBBCH73O4xswx4MSLcHaVJ4s6OIIhAlsd/DfK13nSiIGNrPPQ t77h1m5vxW3S02S7BhHbJCrn9rNTRkrW1afDyt7yUpNWOPiR9mVEVZDfTtuNPaH9yxbJnfT2PPN 7RGi0Th6/RK03 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: 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 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