From patchwork Wed Jul 3 13:31:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 11029633 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C62C0138B for ; Wed, 3 Jul 2019 13:30:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4E38284C8 for ; Wed, 3 Jul 2019 13:30:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A90E228807; Wed, 3 Jul 2019 13:30:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5CD24284C8 for ; Wed, 3 Jul 2019 13:30:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 55DE16E138; Wed, 3 Jul 2019 13:30:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id E3B5A6E138 for ; Wed, 3 Jul 2019 13:30:53 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id p11so2838765wro.5 for ; Wed, 03 Jul 2019 06:30:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6WLXf/VCXC4rlq9YhY4PmzJ42e/EBWSBPmZlwxVdmWQ=; b=a+7F6ufKu07CJfDM11ctA7n7CT/8dbJ/UJ519soIqVhadNc0nMGnkyrgSEnEf1F/8v oEiSRkQh/CDVRwNs9ttirQf+g8nBfdjX4UuQimibxTCJlJB2iBh0JHBhKKqu5f9yIN59 sCyyLN+v0iPpx+/K2LpNszAAgroA9wkTNZZKPZ3HcV5Wdmt52dQYIYND/TeMSiYz/EKL HFvz4XpTAF6Kr9s9+awPJBjUwx2Txy2K85tB9t79SzZB/GK6/K25QcUd1sTWnV2CFKOK lAHmrUleUN958BNmpmAbDt54mHUpPBaIWjWB+zXDUaxJgpHywC8VtVCppUEEIDo8W0eS f6Ug== X-Gm-Message-State: APjAAAVtpqT/++pYzXANNg0JHOsWF1ozsAyn6n5W+3X5oxu1/NoMGHU9 MaQXlu6zQwTSZXE3mutcNV9Xsd8m X-Google-Smtp-Source: APXvYqyUCkd/LThAkGGf1z1VJKcVBrKl4qrWywB3lYQMQ86qrn5JWnKCNY2F6yPpbI9yUTgpgNUbYQ== X-Received: by 2002:a5d:6b11:: with SMTP id v17mr15266716wrw.323.1562160652105; Wed, 03 Jul 2019 06:30:52 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id g10sm2353263wrw.60.2019.07.03.06.30.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 06:30:51 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] drm/vmwgfx: check master authentication in surface_ref ioctls Date: Wed, 3 Jul 2019 14:31:02 +0100 Message-Id: <20190703133104.3211-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6WLXf/VCXC4rlq9YhY4PmzJ42e/EBWSBPmZlwxVdmWQ=; b=MWo+k8bzDd7sEhOcDIGJEA0eRhKjmBFSeevzjgU3leq1MxtV6rkzWICSNIJYuyWXPx 6+k0VaK7vfd2zsds+AL4tU0o3q0+DQ68jg+zXsUZN/3f3eWkRD/vqvdjPNZpvAoRbZuu k/nibHBROOeFZFRj2JWr4jn65Mz12H5jCqNzb8lfJar9swIWoHY0+73ZMJBELDMiQhlF lAfHJ1NWpMAgvTnltz14Um2ZH/KWGmxHvbg6RS5b+7j4Q1bO1aCYcLq1YcEuN23PW/TQ 7n7SKETSuRjRyj0LkzOQVbpqsaWDbXFJTGUFIQK1olGlWt8ryOoF+1dJ+BIqt+HtA3HG KXVw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: VMware Graphics , Thomas Hellstrom , emil.l.velikov@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov With later commit we'll rework DRM core authentication handling. Namely unauthenticated master will be allowed with, DRM_AUTH ioctls. Since vmwgfx does additional master locking and DRM_AUTH handling, this will not matter almost all cases. The only exception being using the legacy handle type in the family of surface_reference iocts - all handled by vmw_surface_handle_reference(). Add the check to ensure such clients do not access more than they should Cc: VMware Graphics Cc: Thomas Hellstrom Signed-off-by: Emil Velikov --- I'd like to merge this through the drm-misc tree. Ack and rb are appreciated. Thanks Emil Unrelated: worth moving the is_render_client check alongside the is_primary_client one. --- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index 219471903bc1..1f5146c95785 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c @@ -940,6 +940,13 @@ vmw_surface_handle_reference(struct vmw_private *dev_priv, user_srf = container_of(base, struct vmw_user_surface, prime.base); + /* Error out if we are unauthenticated master */ + if (drm_is_primary_client(file_priv) && + !file_priv->authenticated) { + ret = -EACCES; + goto out_bad_resource; + } + /* * Make sure the surface creator has the same * authenticating master, or is already registered with us.