Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1701125pxb; Thu, 16 Sep 2021 13:21:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQkeZ27g3p+UxKGizm+bAzZYyriAeWi/YnghyS/f3NtHzqA2X8ujTLY2ILYXVlej8RBtun X-Received: by 2002:a5e:c603:: with SMTP id f3mr2232277iok.14.1631823690497; Thu, 16 Sep 2021 13:21:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631823690; cv=none; d=google.com; s=arc-20160816; b=Zb+Qzgc1soQS3MCIAE5r6AWDaz1VnH5N/KoGhrEFFoxG3OUajfkXHzQ6bTXedCkcoN 0bruvzQieO2gDosNkavnONjUEol/k+17cyl9+Uvsd0wIl+IgfIT0TQArf4jU2je9MZob kyk+l8ag2lyaVqzmgJ+OCe4I5Jf8Wn5ZgPwdOMhC6joltlMXz11/RCIzbhJLDkCodt3H fmRqTyjU3e6r76oJDgB+YQe6hgQZRjEmqGk4QqBP0wJmCi2i85iVSolPFID3NKdvxxoV lZ2yqLk7raUD+vuFN+OmPfsrq/RnljyUeClQN2bRKez5U1A5opzbbQlpZjEMPQKtZZLO ZRlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j3eOW/haWr/ZHDH39Sdt0UdVvbaKgHyFInnKGOAMXHU=; b=A4Y1zs0wjSoAfEMpRWtjhp2OKDjcylcviEwS2vyyqnHDjbUXx2k4jhBA8EJRGmTMBd +Lh7q5M2m7lF3cXxUtZKPy8q5pQHc1dAK9H7hDJqhf4GOPZQpBQDh6Ix9vic/XuI3MUK wPFOsabqmFV8cw3LWDbKF0xG/gHPKPn/1lig8XPNxmWpewn33mjyfGu3D96fm0mYtocx D7Y5gOPl4HBGv7UWM2I0JOzAWB8kUKVy9Zx4h0bSIZYthr8yNaZ6M3ou858+LHtXGcwO SG7svR6H0aav0AFVraaQ37wr2hFY0LCz2zQ9+vLURVq0UbS1cVemGiRYJFOV6vd+0qSJ 0ppw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wUWyu+C8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i4si3882864ilj.162.2021.09.16.13.21.19; Thu, 16 Sep 2021 13:21:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wUWyu+C8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232579AbhIPQZ2 (ORCPT + 99 others); Thu, 16 Sep 2021 12:25:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:55070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237304AbhIPQR0 (ORCPT ); Thu, 16 Sep 2021 12:17:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9201F6135E; Thu, 16 Sep 2021 16:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808748; bh=vIOPACp0GIzwiZ78cHSgUvhPGpXcKbTs+u+stPp/E78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wUWyu+C87A4QnmTq+OhQgolOOncVX+SLBmup2oF6hZsQL8IklV8SJJbEl5Pcgc8xl qdIHrDfFu26AtdsjhOXLN+grAuUx5ogi6J71uypWTI/uhOTZZTgo8ytIHa2HrffrT7 79F0jzca3CjyEDYH7FJVwWhc6JFxm/DxHQ6k5SNs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Desmond Cheong Zhi Xi , Daniel Vetter , Zack Rusin , Sasha Levin Subject: [PATCH 5.10 206/306] drm/vmwgfx: fix potential UAF in vmwgfx_surface.c Date: Thu, 16 Sep 2021 17:59:11 +0200 Message-Id: <20210916155801.069393715@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Desmond Cheong Zhi Xi [ Upstream commit 2bc5da528dd570c5ecabc107e6fbdbc55974276f ] drm_file.master should be protected by either drm_device.master_mutex or drm_file.master_lookup_lock when being dereferenced. However, drm_master_get is called on unprotected file_priv->master pointers in vmw_surface_define_ioctl and vmw_gb_surface_define_internal. This is fixed by replacing drm_master_get with drm_file_get_master. Signed-off-by: Desmond Cheong Zhi Xi Reviewed-by: Daniel Vetter Reviewed-by: Zack Rusin Signed-off-by: Zack Rusin Link: https://patchwork.freedesktop.org/patch/msgid/20210724111824.59266-4-desmondcheongzx@gmail.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index f493b20c7a38..f1a51371de5b 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c @@ -866,7 +866,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, user_srf->prime.base.shareable = false; user_srf->prime.base.tfile = NULL; if (drm_is_primary_client(file_priv)) - user_srf->master = drm_master_get(file_priv->master); + user_srf->master = drm_file_get_master(file_priv); /** * From this point, the generic resource management functions @@ -1537,7 +1537,7 @@ vmw_gb_surface_define_internal(struct drm_device *dev, user_srf = container_of(srf, struct vmw_user_surface, srf); if (drm_is_primary_client(file_priv)) - user_srf->master = drm_master_get(file_priv->master); + user_srf->master = drm_file_get_master(file_priv); ret = ttm_read_lock(&dev_priv->reservation_sem, true); if (unlikely(ret != 0)) -- 2.30.2