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 11505EB64DB for ; Fri, 16 Jun 2023 10:32:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345008AbjFPKcf (ORCPT ); Fri, 16 Jun 2023 06:32:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345010AbjFPKbM (ORCPT ); Fri, 16 Jun 2023 06:31:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63EE05261; Fri, 16 Jun 2023 03:27:52 -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 493A8635F7; Fri, 16 Jun 2023 10:27:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 298AEC433C0; Fri, 16 Jun 2023 10:27:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686911264; bh=pIJzDSdZm6E+NnIwO57Xq2I4agMZenBysCO9cU1z8zM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uZOwqEp0dUDEw6XptxGdY/6dzWRqZucSy3heMuoL+1+JUwFIgUMumnPef8TUz5iKi Et2tk81FWfxCeD8WOUDWu1Y5ZegMKVth+3i6posyAvzRQOFhZgXFF6ol2/RhGJ+pOj GRdXrf9cp/EdYUV0pBDlS0JMLrEm9HUZCOo41DiNWSQfPoAQnoSajKEszcU1535YhL 0pQA03H0lfsdDNwqj9dJ1szpYY8QpcN0rwAEKj03f+WOn0PBUOcYyMWvvvF7Khg2zM 65h6blI5suCCME1fhKS9yUSNg4k4e2XAyru6uUEpMkZxtP58w0pufw6JU9Pvnyeg5d CAcjgHCqouUzw== 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.15 11/16] drm/exynos: fix race condition UAF in exynos_g2d_exec_ioctl Date: Fri, 16 Jun 2023 06:27:14 -0400 Message-Id: <20230616102721.673775-11-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230616102721.673775-1-sashal@kernel.org> References: <20230616102721.673775-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.117 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@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 471fd6c8135f2..27613abeed961 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c @@ -1335,7 +1335,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 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 83CC5EB64DA for ; Fri, 16 Jun 2023 10:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dKyTib98dd014k/2GIdt6qLsjrfJ8hDSa8RCTZDcfRQ=; b=yxOMzFGuG2AAJd XYFzLDAXJ0xwHLSGlo7EcobN44gQA6j/0iLX8+8QdFShguG3OWWO2BYocopd215Lyf27RsykUda9Y 42HVDKigFvLOsX1TIaDDgJNWL+XXGK5GAg7Jxg01HTb++zzDayMye/fNVbLnn3FhvGw/Nx8Q55PiE jyHBwROGhXxB+f16eDAsMRNZeWfAtaAT6ovastEuJjvBrIFz8I14lq5o7p3OAQzx5aB5pipfqyoRq rNTPzFoNJ2y1vfOL4QFb19dCc7to0j5cng1QtebpmwRgWKzlm1t+zjS7iC658k8N15qQxGX87+Gs0 XXvPMktsfUCaLbkVoz0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qA6gL-0002CJ-0u; Fri, 16 Jun 2023 10:27:53 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qA6gD-00025m-26 for linux-arm-kernel@lists.infradead.org; Fri, 16 Jun 2023 10:27:46 +0000 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 328F96362E; Fri, 16 Jun 2023 10:27:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 298AEC433C0; Fri, 16 Jun 2023 10:27:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686911264; bh=pIJzDSdZm6E+NnIwO57Xq2I4agMZenBysCO9cU1z8zM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uZOwqEp0dUDEw6XptxGdY/6dzWRqZucSy3heMuoL+1+JUwFIgUMumnPef8TUz5iKi Et2tk81FWfxCeD8WOUDWu1Y5ZegMKVth+3i6posyAvzRQOFhZgXFF6ol2/RhGJ+pOj GRdXrf9cp/EdYUV0pBDlS0JMLrEm9HUZCOo41DiNWSQfPoAQnoSajKEszcU1535YhL 0pQA03H0lfsdDNwqj9dJ1szpYY8QpcN0rwAEKj03f+WOn0PBUOcYyMWvvvF7Khg2zM 65h6blI5suCCME1fhKS9yUSNg4k4e2XAyru6uUEpMkZxtP58w0pufw6JU9Pvnyeg5d CAcjgHCqouUzw== 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.15 11/16] drm/exynos: fix race condition UAF in exynos_g2d_exec_ioctl Date: Fri, 16 Jun 2023 06:27:14 -0400 Message-Id: <20230616102721.673775-11-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230616102721.673775-1-sashal@kernel.org> References: <20230616102721.673775-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.117 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230616_032745_742490_7503C683 X-CRM114-Status: GOOD ( 12.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 471fd6c8135f2..27613abeed961 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c @@ -1335,7 +1335,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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 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 6D0C5EB64D7 for ; Fri, 16 Jun 2023 10:27:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C55910E5F6; Fri, 16 Jun 2023 10:27:49 +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 B7C9110E5F1 for ; Fri, 16 Jun 2023 10:27:45 +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 328F96362E; Fri, 16 Jun 2023 10:27:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 298AEC433C0; Fri, 16 Jun 2023 10:27:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686911264; bh=pIJzDSdZm6E+NnIwO57Xq2I4agMZenBysCO9cU1z8zM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uZOwqEp0dUDEw6XptxGdY/6dzWRqZucSy3heMuoL+1+JUwFIgUMumnPef8TUz5iKi Et2tk81FWfxCeD8WOUDWu1Y5ZegMKVth+3i6posyAvzRQOFhZgXFF6ol2/RhGJ+pOj GRdXrf9cp/EdYUV0pBDlS0JMLrEm9HUZCOo41DiNWSQfPoAQnoSajKEszcU1535YhL 0pQA03H0lfsdDNwqj9dJ1szpYY8QpcN0rwAEKj03f+WOn0PBUOcYyMWvvvF7Khg2zM 65h6blI5suCCME1fhKS9yUSNg4k4e2XAyru6uUEpMkZxtP58w0pufw6JU9Pvnyeg5d CAcjgHCqouUzw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 11/16] drm/exynos: fix race condition UAF in exynos_g2d_exec_ioctl Date: Fri, 16 Jun 2023 06:27:14 -0400 Message-Id: <20230616102721.673775-11-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230616102721.673775-1-sashal@kernel.org> References: <20230616102721.673775-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.117 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 471fd6c8135f2..27613abeed961 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c @@ -1335,7 +1335,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