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 7477313AD0 for ; Mon, 26 Jun 2023 18:14:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E678AC433C9; Mon, 26 Jun 2023 18:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687803248; bh=ngZd97GJO9P6sC4jMSqvWLbJfghbLBb2vX/wMBK7D4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BgSNMR0VrcVSPrFAVMIX77sf7gPeEKRbcaDamdMILsTAh4thFDQbmVkHlJ6nc73wa r+dEmr8+jzlS+JeNI72RR2tQCG0EpUKzzlG+2yedIIl6AgDXN2ABu/rSUnvv1JpL6z t09nvZNYfAewDtQfWyt1J0rR4yyclIRTAxEVFTQw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Min Li , Andi Shyti , Inki Dae , Sasha Levin Subject: [PATCH 4.14 23/26] drm/exynos: fix race condition UAF in exynos_g2d_exec_ioctl Date: Mon, 26 Jun 2023 20:11:25 +0200 Message-ID: <20230626180734.603526473@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230626180733.699092073@linuxfoundation.org> References: <20230626180733.699092073@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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