Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp451330pxb; Thu, 9 Sep 2021 04:55:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDf0HbHNgYp1Vd0ziokdwkmuaWXpImaJricGjAsjR/2RTeGmDODjhyU7OTS2I7lGkDU3so X-Received: by 2002:a17:906:7855:: with SMTP id p21mr2951976ejm.330.1631188500113; Thu, 09 Sep 2021 04:55:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188500; cv=none; d=google.com; s=arc-20160816; b=qu0TxI2LfNXyLRfwBWSnA2VaTWJcc0L6+l3c0wzDWav8TG3RiGmSv2Uy7RK7gpGxPC zaJV7d5LcL+bqnNNnxXlkzUqcCy5qHWvJejdhHUQ68UjDWEEiB2rbeS2rmz02MWzPd+l Bq/JYmJbc15swNjca7pZ3r0RgJFmNFEKGYppzS5O/3HcC6hGfG5f6f6b6YIBBsVMX/by hXHbMfZoI4K5Pt0GuyzeX5VhPNdSgQhvTZ4u678iQcmbmILl/KWrge2AS3SUI4BSp56b LuoXoWONXG2J3WJN5anYeHdpmQ+sIX3AA3eM6uqMoqjpxuGgEzTyXBY2vowFGqsWySmV DvpQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=I91es6MUEmqEdKEW7ovbhiSksG3iXQvIT6yKFkHEUMg=; b=zYGsMT56Bmk7gCbfArWx9VsLB4DxYwgEb4rprU3p4e5Ql2Q5OOedCtH/UdddsVUUI6 +ymqsUzrxGZdAwfuSkatEWG7gC5aN7S/0uNwL/OKXkLkNwYEGvo5zeC3H1dxodvMyse/ +Rjw0Id8bUz0QFWpeBDFw4SsP2LjZL7YSrazCSAjcQ1NUgJ8ufr/Q1hWU04/Y8eooo2G VzOQQwEHDbpzGLXm5d3cNQLWwh/E1H4m99PssD8fOQBsRcdyYh9AgmfvYBx4NBusAR1Z nFzRNbLzoRF+h+Fb1eiUfngZBP5s9QFtIxBRljmQ2KGc1iX3KTrW3A5/kocUEtcxArgT 5DWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DbtTe1Ae; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz19si1720106ejb.599.2021.09.09.04.54.36; Thu, 09 Sep 2021 04:55:00 -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=@kernel.org header.s=k20201202 header.b=DbtTe1Ae; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238185AbhIILxy (ORCPT + 99 others); Thu, 9 Sep 2021 07:53:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:55522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241607AbhIILvJ (ORCPT ); Thu, 9 Sep 2021 07:51:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 14C7F61264; Thu, 9 Sep 2021 11:44:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187845; bh=Hzysi7XI1DcfJpjR6tZX1eJDy8LM2R0rL+TZHRs2l5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DbtTe1AetnsrmgrobO0QZAhMVvTRy73eKRVLgJNqM95E1LY1JuR2MVIaIk9dyohtq wifYatLXh25OuUVnR8u54Vp9hKkvwdMry3YgHStZxBqimKALVl/jBn0mgCyw9dYbbN NFsrNXq6tU0YmgtQAewhO56CJCdzFBzI1ItSdQsT0pG/qgvsylbqTTxuh57HbktMv7 /pPjlHd5N7e5B6XJ/X1r1EmnC3ll1Yz937RX5C/2llxqGKWPxfVXCY2cRLcEEJTck8 oMcJwGXrY5K4C8mj+evWct0owpse2DNfLmLkb6kh4G54HNncKsvFkuIxjxcVHJ0VME renTW3oeofr6Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Desmond Cheong Zhi Xi , Daniel Vetter , Zack Rusin , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.14 138/252] drm/vmwgfx: fix potential UAF in vmwgfx_surface.c Date: Thu, 9 Sep 2021 07:39:12 -0400 Message-Id: <20210909114106.141462-138-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 47c03a276515..a04ad7812960 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c @@ -865,7 +865,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 @@ -1534,7 +1534,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); res = &user_srf->srf.res; -- 2.30.2