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=1796452401; b=CLwewHFoUx1CdhWzEOP3A15N0jC8hE6MrZQR6HrePO8DTwc1TZI9BmslND5tFPHRbeLi qGxtOVHdRuUiMj3MdzglNyH9KQjchfdUkIbuxA68xEzNcj4RVI9E4EcvvEw5PTuMymXDK txv7vYcUp98qnil0ReLSvJB33FC/Zyt1vhpgtL8s1c1uKU2o4crWVGJYWyiRCd7lVTmFA 5SEWGIZ7hE2VNqZXGTu6F/HAcmn5Xg7Za5drDEhMwCOY0NlojD8llvYIggYUscdnJINFz 8m9oAfVC4Pm3weJvX8J1Ht3EF3kmeWjehjLLIt65CAJql9DmR46CJYnmSpKS00lsRHw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796452401; 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=5OG1n8EbaukY1a6Gue54les3an60q6FCOwn79zfHAPY=; b=n0AkanpYqkjHe1glpkYToWIzI065YuhVtYthwJ2grz4q1PoLNCDDCs+JEufAjbBQtOLR dnZqNYCJ1M9BndsXGi2okS8QVu2wRIYJPDHSKIM48V+dBsDotioBmUVAu0uNwp7Yv6bNb 1qQe8JHmti04PGwpY5dPZntErtKg53xN2nXYPuT8yV3HaCDHPdIqeM+Fo4gPmwFyjVB53 qA/kwE3Sff2/3z3n75h6aAj9MXuS4sf9Vg0Yx71A1W+i16m/1/z4uOmZoECTfPAXGiZVe rILyGlzhMV40ndFv5EzgWmXqBqhNDsfyi0g2oip61NmMwhopVGesrwluNnaoliK3ewg== 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=HyQmGc0S; 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 C14FF60A3819 for ; Sat, 5 Dec 2026 06:33:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C14FF60A3819 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=HyQmGc0S Received: by mail-dy1-f175.google.com with SMTP id 5a478bee46e88-38190551625so2012110eec.1 for ; Fri, 04 Dec 2026 22:33:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796452400; x=1797057200; 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=5OG1n8EbaukY1a6Gue54les3an60q6FCOwn79zfHAPY=; b=HyQmGc0Sij8tBrp7xtd1oKSDJxds/H6GbxKKZUQwLp1WktljLXzR18OzyQv81eBev5 4Fq6rqYxvJrTvOJIxiO53TNVxA5Ou4chJ+3q3zUKPzTPlh+U/aTBw+gjet5duF2/LlBS hq45WgPf3sAhFnWZffJrTCpikZWFIzc8OMBO0aqKdI0dtn2H+DRuGs731UalHRp3pLXd KIsH4t+wrs2eqUK5E8FTMMJypY53wIjSXVVUNyuHuTtVGAZSBc5Ffz8wchhVgX8DgMcO kMqNjv4OP/b4XKsV/aM8094GOT4in51G4kHorgxWMewtvu8dMHbbMoisMWl818Pddjh6 HHrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796452400; x=1797057200; 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=5OG1n8EbaukY1a6Gue54les3an60q6FCOwn79zfHAPY=; b=xopLGRNn2ye0A09W6X/8z4+Su95UFDGA5wSt5STkpGcdc2c2YXLB2PvwLWDPFuGy23 9iTAlwe/F6XGyQ7B+JS0rjnUfbPmCBdAo4UBn/CJSzWNnPJ9i/9fQ2FzLvUHevPKOVSe SCF/Z559bNMhxcCgBI3VdfWr0uoNG0xDOL3A7P/bObwG4rbdM8Kq1zsxW4oZcRfG176N Bz0NCi+e6znPQbtS+iYKoxZWj3Z6z8B8Y4ywpOsK4fJQ6ZRmkfIHYKXp5HGeM7Q/kba+ 0Wpy0MPPfEN7irGYt4QyotFV+VRkWWT3ERYxu8SMGliZLuiZ/UNYVyugsJtszGLHbtHj fVyQ== X-Forwarded-Encrypted: i=1; AL+hErFnChn8KdlixdDVg6DfDPD+3eTGiBcQKnIP8O7kCJifE71TPDpZQyqYQUU5vhbloNmPSA+v94c=@vger.kernel.org X-Gm-Message-State: AB4q+uFtAro2+GIlRthKGpzOPrHvSAzxA+PNtzNhN371odjdZDX8uIYH v1pGuWl3HhhYrxOEtric59to+Pd0XASjQe2p8cgHmmRjwkk9ynfzDj+R X-Gm-Gg: AZFdTZdzCNInZe7oVM45gn8a+Lnp8/BPtLbIUHp7Ee3zwvsh9cJ8WBVTxoF7JYXJyLt 1miqkg1gVnCFsppwMyEst1D2v0/dSGxT/5TgER9ZARGTyS91egMnLeyhw3oaPdNrExTNg4WGtze 7PjJ8K0OyIzhu5LjRSGa/D4jVln+JMxTSEVNWUR1rNZnwjdDviGcVLK2aoQFt/O37Zsj8Udp7RT dV/TUoMf5dTc7zFMdzFixCrd5vpFmZveY7OF5NXccqVVyCzul7YgTLwJJbtbjcJ50OMsgmvmsMy hbfAziF+GpADwL3pAqPcAI1wOpXcuOPqFJrQw7w9lzKfsk12RUwKpG/aqppR3gIQmTpjQhzwfKx 2X9iuePA78QecAal5VBlcV1WfGf/zsVKWxTLWbWszvzCVYHThjOH0zjX3HU/Dw3suNAZslrXnjx BZA/GxPMsrOw2S7yHhFmE2AYm9Q0hDWQaVXVUPupkWXoeVGfyI4x/dqNC6vm6QtxKMY2mYxqDyy ZvbE9aq4HR3pDW2o44mkV9PwGzX6FOaULOUOeTSN7CL2kWW4oU/nZ8P6/h46+Slxr2t3t8qxtiL DiZTOrt/7B9lL8MJcZqBFbS9ECNbbgr8Kmy8NaK7u4WCtrbkTQR8jSw29EJe3h/KBSU= X-Received: by 2002:a05:7301:9c90:b0:376:b957:bfb with SMTP id 5a478bee46e88-3875218d7ecmr6296961eec.17.1796452399857; Fri, 04 Dec 2026 22:33:19 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 22:33:19 -0800 (PST) From: Praneeth Balasubramanian To: Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, "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 8/9] scsi: qla2xxx: Hold qp_lock when completing command in abort timeout Date: Fri, 4 Dec 2026 22:32:28 -0800 Message-Id: <20261205063229.2518424-9-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 qla24xx_abort_iocb_timeout() removes the original command from the outstanding command array under qpair->qp_lock_ptr, then drops the lock before calling sp->cmd_sp->done(). The done callback completes and frees the original command, which ends in qla2x00_sp_free_dma() or qla2xxx_qpair_sp_free_dma() and their qla_put_buf() call. qla_put_buf() must run under qp_lock_ptr, as its comment and lockdep_assert_held() state, so on this path the buffer is returned to the pool without the lock. The unlocked qla_put_buf() can race qla_get_buf() on the same qpair. The pool accounting is then updated non-atomically, and qla_trim_buf() can dma_pool_free() a buffer that qla_get_buf() has just handed to a new EDIF command, which is then submitted using the freed buffer. This affects the EDIF buffer pool only and needs a firmware abort timeout to trigger. Call sp->cmd_sp->done() before dropping qp_lock_ptr, so the completion chain runs under the same lock as the interrupt completion path, which already invokes this callback with the lock held. qla2x00_abort_srb calls done under the lock as well, and no done or free path takes the qp lock itself, so no new lock ordering is introduced. The abort srb itself never takes a pool buffer, so its own completion stays outside the lock. This was found by an LLM-based audit that checks code against the rules stated in kernel comments. Fixes: 71c80b75ce8f ("scsi: qla2xxx: Do command completion on abort timeout") 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/qla2xxx/qla_init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index ccb039d97353..3d80ead06aa1 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -139,15 +139,17 @@ static void qla24xx_abort_iocb_timeout(void *data) break; } } - spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); - if (cmdsp_found && sp->cmd_sp) { /* * This done function should take care of * original command ref: INIT + * + * The completion path ends in qla_put_buf(), which + * must run under qp_lock. */ sp->cmd_sp->done(sp->cmd_sp, QLA_OS_TIMER_EXPIRED); } + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); if (sp_found) { abt->u.abt.comp_status = cpu_to_le16(CS_TIMEOUT); -- 2.25.1