From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452401; b=ZKPiWNsudzWQmXdEEUF1hW2Dp7Vgy2emu4vLCwq1bU67BASOvk+xKhvKtg3lumybUEMr 5tsbeaCMlr+/GRVxRWVAjMnS7cax2oPtg14zuCaK4HSN3rAB0wXHH11j3yhiWhWDnDeI8 ohxlnsvBvIXWmBWt3LjBFXLIvSf7TUf51pjpcmZpylDpHj7JcZGdsRPXnCJFl4MdITb8L XsKHfH+0DLqnzFQM3NyB8vGvd5zpjd6J61y4BOJLG6MwqDKKP11eogNG+/dU5OJTtF7tG qBs9Y0jRyd17DnqRUpg7/ZPipNWSCSv/Wg+mXGDf/z3uT4qf8mmbIycGVhSsvjNoBIg== 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=aR+CVZAiMMe4b4r6UPxpmwqKLuZ0THKjicoFxxIlAZX1uxtRyZwx/3gIkcayag+wqKqD Cpe1RkgFPv6P7z1iONZjlpVRc8j1MTxYVg/dltTcJpe9lF45wdFJnBDK7BWFBxySVlkXb gVYRIjKIP07H0K1DEFs2dvHGYSZ4PwWTbju6PVGjeOEEwMyMvObs5KS5Q3PvFW/pPA49+ cBUr3SuyngBEEK8mY2EMkkpHx9qUtPx1JzPgseWQoQoLO2Qg1G7zVCSssBAddAVoxuKkG y01CjDyl7pJFOlauiLiDIsIthT/SZp7ZFqEMADVNIpoLLvyVLsjP8mUPJD2BkpZkQNg== 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.174 Received: from mail-dy1-f174.google.com (mail-dy1-f174.google.com [74.125.82.174]) (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 B78C560A3817 for ; Sat, 5 Dec 2026 06:33:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B78C560A3817 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-f174.google.com with SMTP id 5a478bee46e88-38190551625so2012109eec.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=f8EcCwCUh4MnBHs8+5xkZm+tfmPVXllx2mfr+U6V7kk1mh9wjgC7+QUJHrnEonaK9Q g2Ud7Xw8+5sdR+ytrUU+kZLbcnyw7PhIITDFTo46trIfPPbb0s4+Aik1QMv/9Z+WxtDR BQZVxkvr3NxCYuV61pmnOlliMY7CaNXfC54G8nd8xxpHEEBifeD8BQM4gRLmnyH18wKn 9CiySpRRhBkb8WV6sGnG4pgzFxS/unPbPpMquihpvG6fUD2QX2fZ8XIE0qiGiBQrWrgf DD3wRBvXh/IgJEtDNr2I629rxefyY1GhgOaJPaGcttVTgTV/eX9/ETrqhLVo1yocxqDe k3hQ== X-Forwarded-Encrypted: i=1; AL+hErENQ36kYMst++s1TeEBF9ql9g/dKioXSW97cifrwYWKy9XT2t1rR0AXAm9nezO1kn90ff2XX1klUHaqNBk=@vger.kernel.org X-Gm-Message-State: AB4q+uFiZDvvKsyAD68x8qXh9aE/c8xcchirkuaRiYmt1Pa2MwvH7oa0 tWin8T+/lS3BSy4uEDu4jmH1xEPk7mucBzi+HjMMKbgnbzti9hiiNVCxBPkPK4oH X-Gm-Gg: AZFdTZch0G1JPgCk7cqvIDswmXj17SfoPf0mbcd8FoFByQYKSO8X6T+9kAPjBu+DrJt yANiwN0MpFFjPc6UBo+LwOmejMEThu4Wc0G44rFgRmjLR2MWlZbCxjo4E7p0TB1QELVyw5AP2W6 Vt5XtNB4CFe+lJbUdhsjxHkZVchjcNNhbLe25rnx5rv3p6zfUpviHHbQ07Rkne6kjZTxJGm4Z1G CwPXHh1gRNFjd6VaUjB3WOR9fM3IcSMlkkL+HcWyissnfatGooFtiCSAHHnC9GFvFBAuFhXiUE2 ULLd+4P4rqi6iXuYndNgUBr2PT/iVeyGmueC7dipIYXsA4jusQLDQlCeR4zVV+EYrtA+BFChASQ fZDjRtRuKjX/a9dxXV5ZVXjSKz+ew1EOK1BUHd5ppeRDcFZ2BTH4vYadpLi3b9zAucCm05kQr7P rX6oGlwIkLIQKIXZsrzWqmWb/+xlJTlzElna3YGsEBplijmo2+oSOExCAhMRRdF17x8P4lYdJR8 ufQ64P8S9Sa6Wvjx9yMxDGXXGHal60FzO16mjvDelbquvlXRnvIqVwfm3A1koZe/2OIsBmTTash axI9qLkf7UIF6NjCuV6PaB51eGsN8PdUngupbrjtwCSfa9Zrz1Vx+DxRYXBzpE1yCd4= 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: 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 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