From patchwork Fri Aug 2 17:01:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 11073921 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 D6D2A13B1 for ; Fri, 2 Aug 2019 17:02:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C841E288B4 for ; Fri, 2 Aug 2019 17:02:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B97EC28712; Fri, 2 Aug 2019 17:02:01 +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 BA2FD286E0 for ; Fri, 2 Aug 2019 17:02:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8B6EF6EEF5; Fri, 2 Aug 2019 17:01:59 +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 7BE626EEF2 for ; Fri, 2 Aug 2019 17:01:58 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id n4so77976562wrs.3 for ; Fri, 02 Aug 2019 10:01:58 -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=HMOp/sUEkCBx7pv/B4UxPv0plz7e7QgzlffeZ0R+R1k=; b=bCNEluPStFhYgQo29sQoQXqX87ugcnvggDJWvl9BvIg/l9VcAtPad/viAzPDVhpDob 36yJhc1Wzfy9WZVHoi4pSDTvU/a4CUPkV95Tn9quyj0HF2JlNfwRU3k6QzoJWMUAdQCP LyTMC7D0uTK3EOBLW4bQX/03ijyblcaoYgWKERpFHRnR4IAVQ7a8P0o7vVb+Wbh4m4Qm Dp8ZqWa5RR0G8+mmQy/bddHdwMd+omAoArYCJ6LsX3LORw2wFnW+hI2Iqo1S7OsAfsT3 CSDa+T6eH3flK5J2hBISidBRvMDV0vnnPRXxt8LfhSohPoW+NoCATfC8/VHeV0aKIaH0 dktw== X-Gm-Message-State: APjAAAWop0eI80pOywHUZ+f+rurdA1a1uAaa90znn1D+1MKdmyMhy2yV 7W4ilLyy8GsqGpZIcLo3vp0s8prW X-Google-Smtp-Source: APXvYqytG4ZdVQDn1mEMdRgNR1MAT6q4S2cjZCz/FTkj4SZiNQ5YE5mCz9advs+lWvMWQQo7lZ6HwA== X-Received: by 2002:a5d:4085:: with SMTP id o5mr145890720wrp.101.1564765316851; Fri, 02 Aug 2019 10:01:56 -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 f12sm82823008wrg.5.2019.08.02.10.01.55 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 10:01:56 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/2] drm/vmwgfx: add local DRM_AUTH check for PRIME TO/FROM HANDLE Date: Fri, 2 Aug 2019 18:01:16 +0100 Message-Id: <20190802170117.10942-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=HMOp/sUEkCBx7pv/B4UxPv0plz7e7QgzlffeZ0R+R1k=; b=p5o59K82Ulnu491CNJoIwAh+QOBR9XFEh9JA38qLRzG7CgkTwlq7W1ABoFd3qYvZ+o PAeNUzC91lBR61dVoivY58oMP6cPDFyhnRI0aECR06lJ1tGdjVZiQ5Qm2hRxku0Pkamn 0yTnPi2r/mXqB5r3xiKi5f92lxJhEP0oVJIU1SeDqtK0X/WCFOElW9xxLF+5eJpa62p2 WTrrz1gsqJotfFkg6UzAZAk1VjkOxjoSJzM6ucfcF24nfXFGk2JYhzUtw5z0hYXhw1Q9 sHQ9eYzS4YMGr2LUzi25R3ac5HD4Obvz4y+x9EdDyS5EPKVCKfM6qpakcKy08+UD+dyI rt/w== 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 , Deepak Singh Rawat , 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 Realistically no drivers, but vmwgfx care about the DRM_AUTH flag here. Follow-up work in this driver will properly isolate primary clients from different master realms, thus we'll no longer need to parse _any_ ioctl flags. Until that work lands, add a local workaround. v2: Use bitwise or (Deepak) Cc: VMware Graphics Cc: Thomas Hellstrom Cc: Deepak Singh Rawat Signed-off-by: Emil Velikov Reviewed-by: Deepak Rawat --- I'd like to merge this and the next patch hrough the drm-misc tree. Ack and rb are appreciated. Thanks Emil --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index cd0d49d8a8da..53afb1d597e8 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -1134,6 +1134,15 @@ static long vmw_generic_ioctl(struct file *filp, unsigned int cmd, } else if (!drm_ioctl_flags(nr, &flags)) return -EINVAL; + /* + * Little workaround until the vmwgfx patches providing isolation of + * primary clients from different master realms land. + * With that work, we'll no longer need to parse _any_ ioctl flags. + */ + if (nr == 0x2d /* DRM_IOCTL_PRIME_HANDLE_TO_FD */ || + nr == 0x2e /* DRM_IOCTL_PRIME_FD_TO_HANDLE */) + flags |= DRM_AUTH; + vmaster = vmw_master_check(dev, file_priv, flags); if (IS_ERR(vmaster)) { ret = PTR_ERR(vmaster); From patchwork Fri Aug 2 17:01:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 11073923 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 3D7F0746 for ; Fri, 2 Aug 2019 17:02:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31208286E0 for ; Fri, 2 Aug 2019 17:02:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2579F288B6; Fri, 2 Aug 2019 17:02:04 +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 A1A29288B7 for ; Fri, 2 Aug 2019 17:02:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 995956EEF7; Fri, 2 Aug 2019 17:02:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5301E6EEF2; Fri, 2 Aug 2019 17:01:59 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id g17so77895851wrr.5; Fri, 02 Aug 2019 10:01:59 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=VY2A6whCZJMFwm69hfn5FnK7Z+9ydQLngkA0tgQebjc=; b=EaM+Vae5Pn6zTmcZwugfyMQkLZudQD1JtjpechP6u3b9SGXuAEXTlua8APst/dhwr8 ZzLh336ykO2dvOvcnhapdR0E9qg0T7jq45Tb1a2q+d7fAUYPSM1bltDPZI+I6q2aYYMa 5Dnm/gSKQn3/xciZURZYOva6G96Qs/ewr8wigM8vRqw4lcIF19B8D8+AV6fenQ3px3PH Eh9V3vThjVKvUI1KnPk8nkbiYcpWYvMNBB3LgOSKt3ty2Qu9g02fk0pkKadlJMM5YGdN TDAdtdXOVUJ3Te7gaxBEmNNT6M+t3kpcIw2cCjLBMVaDcCpych3jyh89FA0TIDBW2de0 uNFw== X-Gm-Message-State: APjAAAXJfzPt839fBb4tTfjXDUXRu+3j1k9fXHAGa8V8dc5d85a1d9CD iwTkinbpGDlvc0UubQFbdHJBN3zb X-Google-Smtp-Source: APXvYqxkfTtOZg0YEisbE5loyC6VE5Wup6Ka0ZkHIbVmtziWpXVacIxM0nmTnQyGEAqrtt4oIYHGzw== X-Received: by 2002:adf:e941:: with SMTP id m1mr8210167wrn.279.1564765317696; Fri, 02 Aug 2019 10:01:57 -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 f12sm82823008wrg.5.2019.08.02.10.01.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 10:01:57 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/2] drm: drop DRM_AUTH from PRIME_TO/FROM_HANDLE ioctls Date: Fri, 2 Aug 2019 18:01:17 +0100 Message-Id: <20190802170117.10942-2-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190802170117.10942-1-emil.l.velikov@gmail.com> References: <20190802170117.10942-1-emil.l.velikov@gmail.com> 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:in-reply-to:references :mime-version:content-transfer-encoding; bh=VY2A6whCZJMFwm69hfn5FnK7Z+9ydQLngkA0tgQebjc=; b=cPgyjXpu/Nxra3FuO0krVazInkbV12FW0ll5EtiGHDrC9hnPhNN5BcIAkjiajvxI21 H2gOy9PfuGSUU4QBuLQ2ymvvDO0tcK6ydvBlFFakYmmxl4rp7bJbUv1cUnIPvK8TzeJq U/uygpjAjLilJnl1QLdGe+45KWW6HRGnSH6AJkKaj1a/ulSuRS/g5CBhqRe+RFdccPd2 Ya+2N0HuvcjAZYOFcyyuYEcH5uu4QOKWnft9biCCfbVOTLmaSnAnn75QNuF9DrqoK9jY fNUyMvm9nWlNft+Delho7tvQoxCWcO/znEwK8q6UV2tI8CwKc4vvpjO93kDLhQtrOtvD qUxw== 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: Alex Deucher , emil.l.velikov@gmail.com, amd-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov As mentioned by Christian, for drivers which support only primary nodes this changes the returned error from -EACCES into -EOPNOTSUPP/-ENOSYS. For others, this check in particular will be a noop. So let's remove it as suggested by Christian. Cc: Alex Deucher Cc: amd-gfx@lists.freedesktop.org Cc: Daniel Vetter Acked-by: Christian König Signed-off-by: Emil Velikov --- drivers/gpu/drm/drm_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index f675a3bb2c88..867ab4e50374 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -647,8 +647,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETRESOURCES, drm_mode_getresources, 0), - DRM_IOCTL_DEF(DRM_IOCTL_PRIME_HANDLE_TO_FD, drm_prime_handle_to_fd_ioctl, DRM_AUTH|DRM_RENDER_ALLOW), - DRM_IOCTL_DEF(DRM_IOCTL_PRIME_FD_TO_HANDLE, drm_prime_fd_to_handle_ioctl, DRM_AUTH|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_PRIME_HANDLE_TO_FD, drm_prime_handle_to_fd_ioctl, DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_PRIME_FD_TO_HANDLE, drm_prime_fd_to_handle_ioctl, DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANERESOURCES, drm_mode_getplane_res, 0), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCRTC, drm_mode_getcrtc, 0),