From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7B83EB64D7 for ; Fri, 16 Jun 2023 10:38:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345463AbjFPKiW (ORCPT ); Fri, 16 Jun 2023 06:38:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345643AbjFPKfw (ORCPT ); Fri, 16 Jun 2023 06:35:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A76E35A2; Fri, 16 Jun 2023 03:29:34 -0700 (PDT) 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 284C662B57; Fri, 16 Jun 2023 10:28:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26622C433CB; Fri, 16 Jun 2023 10:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686911316; bh=dvZLVkGEa++hSp8Eo2o/6Ny0GI3g+KkcjWoiXhghWGo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HQQ9peS6ItdVD1YNEnaxG9w/+PN+E0HWDV7wlmlkB9PimNnbSYNBVUoLzreB5M0Mh EFXbgasdjy4PwCcF2YoRvTKZj8h5pFcijbpzSePZP+qjmukxiStT39ez1NeWNF99Un d4RywRlCv/W2MRPCo9RTJjm151AWUzW0wjWACRqXtA8MX660UExkxLiYlq6UmKnPvY P3du5s4RBwIq3zsPp7p8XLpnqt3ghj1L0WJ5IaZWS69VlzP8gCMjMggyxOe4PFkE4q bCKODFcek9hgiia8ID+e8Z+KBRKOgPfsHQAhayfEhfvJy7iTTmprQ0PO2tavF9yNiK YyR2x1FZGAe8Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Min Li , Andi Shyti , Inki Dae , Sasha Levin , sw0312.kim@samsung.com, kyungmin.park@samsung.com, airlied@gmail.com, daniel@ffwll.ch, krzysztof.kozlowski@linaro.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 6/8] drm/exynos: fix race condition UAF in exynos_g2d_exec_ioctl Date: Fri, 16 Jun 2023 06:28:19 -0400 Message-Id: <20230616102821.674153-6-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230616102821.674153-1-sashal@kernel.org> References: <20230616102821.674153-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.4.247 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 fcee33a43aca3..2df04de7f4354 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c @@ -1332,7 +1332,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