From patchwork Mon Jul 22 17:40:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 11053199 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 D99D213AC for ; Mon, 22 Jul 2019 17:40:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5372285AF for ; Mon, 22 Jul 2019 17:40:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B657F285C8; Mon, 22 Jul 2019 17:40:48 +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 63291285AF for ; Mon, 22 Jul 2019 17:40:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8384789D66; Mon, 22 Jul 2019 17:40:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0099089D66 for ; Mon, 22 Jul 2019 17:40:45 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id u25so25788159wmc.4 for ; Mon, 22 Jul 2019 10:40:45 -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=O6zWc+qtpfK3HmYe41czfRjZwy2r8hIKE79IIn1sh+S+RWK2f1nTsJ5Kv2+n0ywWJF tq+l4CcSYuhKVatnVQit3axAZbWPxFhNcEAmH0PmEntCnXre8q5uBQoi6qLUjgTKQTCV prLHo6N83WKnNquiQ37P2jZmXEKNTVDhaCx5LDkxY/2NJUobyhGRz6ObhR19Ywhybnul aXmhB02hnmxUEaK4ZfcdokQszYx5yOGKwdaBUir+viD/K+b6xHVinBYc2ll57Sjj+ZB5 Xmfrob4oOB8PXskjuD0PXkpUHmQ8V5zMBFFSCXkyrg67n6v6UYsX7JIrBLBMd1eqJhqT EzGA== X-Gm-Message-State: APjAAAU036xD+RC7LzZvQmBiGT+E0jRxMbLRNUyg/zK8zFePgeq+CHsg zwFuP6jrK3bLo587Wso7byvVA7S+ X-Google-Smtp-Source: APXvYqxBUemj0LfPW0SuEbZhAVOevBPBvt4wWKQu9tsovyvWhb9M5FC7amw9aXU4d/PzPA+m8jFJUg== X-Received: by 2002:a7b:c748:: with SMTP id w8mr61458994wmk.36.1563817244249; Mon, 22 Jul 2019 10:40:44 -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 b2sm51844663wrp.72.2019.07.22.10.40.43 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Jul 2019 10:40:43 -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: Mon, 22 Jul 2019 18:40:23 +0100 Message-Id: <20190722174025.9830-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=Q+dES5Pmm2j56Y+dHXJC0nMRCyVvY5BK8u8+qr9pXVgNGJ3jMH/BMsEiSKRTWsymr1 8DBSvIKkHZlah+zjf4eWx/xe+pYrWZPWBZ0AX3lyt2ImciDpFW8pWQ29sRugnvN5BAh/ k/cjYltD3pWJBk9n6/K7wNQk8D+4VUQ7DOpMdS9b6PnZH9P2cthSfq02GBIHi99qWOG9 /Ka9cf41LKbdJ8c/SAP6SZOJl9Xhkb8uCUKG3KUMEsF3Lz6K/Jts1bm3O9Fdrn0DJtDD l4n+Cq6McvMhVcX5bAYDfdFTfOuzQLexXXrvF7G/3W2Fgi7z0aaPNhcj+qZaR8qcRsUO EG6w== 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.