Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1801105pxb; Thu, 16 Sep 2021 16:16:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr0gY+lcm9z0puqDA4W8hb48Fyw+mfj0PSNlDnfrUG4LMpmHZT9nTKGDAFaqTUTBQbORA5 X-Received: by 2002:aa7:c0ca:: with SMTP id j10mr9008463edp.146.1631834193320; Thu, 16 Sep 2021 16:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631834193; cv=none; d=google.com; s=arc-20160816; b=tsefrbS5EGnyuiIENJx8YxRAcauNaG2I3Re3lmNwvKTR0pwojxhTMvgLOB5VEaAguG FOEwL1pNE3QU0ja+TSAwTR1bgju2Etjyo5HvmLYtneOI8QC0Q7gDAjoqlgrODh+bhbRw /mu3BrX/mZ68u39QKHjEoIw1OWMwsSJ77+jtylFZAGm4gH/gtNqCVr1wpgVFP8Hspa8W 5li12i17saHLCmUXtzGWAi977rLtuiax4wKin6ZSvPvhHA9FFBnJ+/IuLBFAuoU27p7v a8swfiKKrRWVslk1kjDw086j2IipGNcohbd5Vo1ecOBUQ0AP8AlMIT9QLA4S2AqaNdc0 DEPQ== 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=ebbh3lm9nIiTllXhkbFBIGqx5YI2ilO3LAZ4fZ2NZr8=; b=OBamrGWg20Jgfi6ONH9CWYavdtYYCmMkFBlWcfv8PqdqPdY0vAZCTUNNjMUTlvUAol jp/L/xXtppYksjHJGmeofyWgto/WbryHtliWmRbnSYC+7HGAlDZQxopXugamaZ+iiX2l raaeSYVfCLfNMbsTnatwnrXcOdGzlfHhw8AZpRVYhcx1rFjenEIwMvyjjtASuix6BLVH 25/2i2ERfeThYQcQDEte92BX/7concEsmft8oNwendZfGkCwUUrQQhPDS6KqZ0PTAcAc O3zkRvN4lk/7jzysS4Xm0pYuS/sKqFxNHoIOdYJIW+ttg3iXpxI8msV9tORzesZlBU1J fXcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rncbJjnw; 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 k8si4725343ejk.222.2021.09.16.16.16.08; Thu, 16 Sep 2021 16:16:33 -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=rncbJjnw; 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 S243649AbhIPQz0 (ORCPT + 99 others); Thu, 16 Sep 2021 12:55:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:36928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345722AbhIPQuj (ORCPT ); Thu, 16 Sep 2021 12:50:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3D9B960F92; Thu, 16 Sep 2021 16:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809707; bh=VK4cR/Kme6NffHumA+SnASBM6WDsCiW7w2C6aNEn0NE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rncbJjnw+ebnm3l3boW9pBPAsAr8Rz1cbtOA8fNVP+CssVV28DXixUTYqxzjgXgAA CwFRqMPzHo7YLwtf4DwLD9QALsWX1b31G+jCALMNTfnoT7y0nb59nRpOlnwBF0neYu TYU3TBf37U/gaPTWDvGwhUeqUpoDXyPl5G+WSKXU= 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.13 254/380] drm/vmwgfx: fix potential UAF in vmwgfx_surface.c Date: Thu, 16 Sep 2021 18:00:11 +0200 Message-Id: <20210916155812.722015456@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@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 5ff88f8c2382..0c62cd400b64 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c @@ -869,7 +869,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 @@ -1540,7 +1540,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