Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39BF7EB64DA for ; Fri, 16 Jun 2023 10:29:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD71F10E602; Fri, 16 Jun 2023 10:29:02 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 83ED910E5FF for ; Fri, 16 Jun 2023 10:28:59 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E7E676367C; Fri, 16 Jun 2023 10:28:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0E63C43397; Fri, 16 Jun 2023 10:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686911338; bh=ngZd97GJO9P6sC4jMSqvWLbJfghbLBb2vX/wMBK7D4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ff9U5pu2CwrOVLPhsrFlqubWn5UH5vYPaCe9LvlX9pbiSBIBXwHanXP1IrjEmIijM MdQFRIOqh5bmpuiESPPCV63MSHR9KFGJhyrdrfLmENwOoob0AGvMbB5iZM3oCmgY6N 9b3llJJHx4Wwm8vJGccVz9geina3ckWqw9WOGxLEADuFsOQyq+MRyfpOJaw3BlkKBr a68DFjdeykAC5nWJpZ9VPa6wpxj86eI7Pi6jSFPb6RO3gOSPi7hB0fBqewZjqETDyz 7mQ0ccpjUKI0CTOFjm+bEUNGl3BoAnnvjBw4X85IQ7kNlsOSr+5J4IMST0OU1oiYAr F+xQEfOKQHDvA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 3/5] drm/exynos: fix race condition UAF in exynos_g2d_exec_ioctl Date: Fri, 16 Jun 2023 06:28:49 -0400 Message-Id: <20230616102852.674366-3-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230616102852.674366-1-sashal@kernel.org> References: <20230616102852.674366-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 4.14.318 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , linux-samsung-soc@vger.kernel.org, Min Li , sw0312.kim@samsung.com, krzysztof.kozlowski@linaro.org, dri-devel@lists.freedesktop.org, kyungmin.park@samsung.com, linux-arm-kernel@lists.infradead.org, Andi Shyti Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Min Li [ Upstream commit 48bfd02569f5db49cc033f259e66d57aa6efc9a3 ] If it is async, runqueue_node is freed in g2d_runqueue_worker on another worker thread. So in extreme cases, if g2d_runqueue_worker runs first, and then executes the following if statement, there will be use-after-free. Signed-off-by: Min Li Reviewed-by: Andi Shyti Signed-off-by: Inki Dae Signed-off-by: Sasha Levin --- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c index 9effe40f5fa5d..ddfcf22a883d5 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c @@ -1387,7 +1387,7 @@ int exynos_g2d_exec_ioctl(struct drm_device *drm_dev, void *data, /* Let the runqueue know that there is work to do. */ queue_work(g2d->g2d_workq, &g2d->runqueue_work); - if (runqueue_node->async) + if (req->async) goto out; wait_for_completion(&runqueue_node->complete); -- 2.39.2