From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1054C33507E; Fri, 17 Oct 2025 15:15:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760714136; cv=none; b=VGb///a486R5hwKXLsP3i0+SEqYWkm4Het6cru7Vwx56uW5K6aPmwLBMQx55H5mlbiPSo6vzLoYDVU0B5rkXBd1qRbynsLXLNw/YkT6kYURIuAr6zoZmjkb8s5O+Qj3Dl2mw+H5zME+qo8O6Z+majRJo4pY5o3YPUXZ9RejMLzA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760714136; c=relaxed/simple; bh=JPWPC4yvsNskWN0YGQYGovhglo71o4tkijCvV90iTbo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RP1lTgE9da+WKrSuYrwum9WA6jePaVNFvlN6pNlGaO1S+nbCHdF2bQ2nr1+gRlmcFXZLg8PerwiPTDOfrA3ZRYfSZGR8XSiu/gezOJBekI6s4oakWQp+60PY9zLnGqFYBg8mCOySdmcUOWy6e3Ffeq6Ja85CRwd10LWIeEBww3c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uaWGRySq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uaWGRySq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4537CC4CEFE; Fri, 17 Oct 2025 15:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760714135; bh=JPWPC4yvsNskWN0YGQYGovhglo71o4tkijCvV90iTbo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uaWGRySqeyjUErOM50lOluxShADaw3u8xQ33bdo8C+PZ08ZqAaDYbqibnjuoCuELB tBrnD2CVF6wkeL9UoTD6IPW+jvuDRf3H3xDRh5gW4e0RpCZMvWM9QQGQozexaRNdeO E0tYhFxdQDGxG8dons9gXGaJAiiWajZbsFs+zoVg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Duoming Zhou , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 6.12 040/277] scsi: mvsas: Fix use-after-free bugs in mvs_work_queue Date: Fri, 17 Oct 2025 16:50:47 +0200 Message-ID: <20251017145148.610375796@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251017145147.138822285@linuxfoundation.org> References: <20251017145147.138822285@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Duoming Zhou [ Upstream commit 60cd16a3b7439ccb699d0bf533799eeb894fd217 ] During the detaching of Marvell's SAS/SATA controller, the original code calls cancel_delayed_work() in mvs_free() to cancel the delayed work item mwq->work_q. However, if mwq->work_q is already running, the cancel_delayed_work() may fail to cancel it. This can lead to use-after-free scenarios where mvs_free() frees the mvs_info while mvs_work_queue() is still executing and attempts to access the already-freed mvs_info. A typical race condition is illustrated below: CPU 0 (remove) | CPU 1 (delayed work callback) mvs_pci_remove() | mvs_free() | mvs_work_queue() cancel_delayed_work() | kfree(mvi) | | mvi-> // UAF Replace cancel_delayed_work() with cancel_delayed_work_sync() to ensure that the delayed work item is properly canceled and any executing delayed work item completes before the mvs_info is deallocated. This bug was found by static analysis. Fixes: 20b09c2992fe ("[SCSI] mvsas: add support for 94xx; layout change; bug fixes") Signed-off-by: Duoming Zhou Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/mvsas/mv_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c index 020037cbf0d91..655cca5fe7ccb 100644 --- a/drivers/scsi/mvsas/mv_init.c +++ b/drivers/scsi/mvsas/mv_init.c @@ -124,7 +124,7 @@ static void mvs_free(struct mvs_info *mvi) if (mvi->shost) scsi_host_put(mvi->shost); list_for_each_entry(mwq, &mvi->wq_list, entry) - cancel_delayed_work(&mwq->work_q); + cancel_delayed_work_sync(&mwq->work_q); kfree(mvi->rsvd_tags); kfree(mvi); } -- 2.51.0