From patchwork Wed Sep 14 14:19:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 9331631 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A910960231 for ; Wed, 14 Sep 2016 14:20:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A76A28782 for ; Wed, 14 Sep 2016 14:20:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E689288BC; Wed, 14 Sep 2016 14:20:33 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 9E3E128782 for ; Wed, 14 Sep 2016 14:20:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 697176E745; Wed, 14 Sep 2016 14:20:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 809AA6E744; Wed, 14 Sep 2016 14:20:17 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id g141so2811014wmd.1; Wed, 14 Sep 2016 07:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=RxFCVzATMNQs9oNOrC7ndrU6qk8W9PwYsEwUkvOI508=; b=cabBIvyvjFjiXF0Ew3qc7UHodqS9f5ZTkHsYnEeFup7wQIGR2EjzvQPsve94g6wAhb zGiX/F1JQvHipsHIicAxEpujnVt5qv0WGrcjiBaNudX+QS2LVWazZ1IM30VObJacWOlT zoO23rD1P/2U1iHr8A8BbJiTxX+I4c/UyRwhPCKTOFMVIt1ZnN4SXNbEvNFODzMnbMnP SWMQDDy+UqIipjejVaN+BFpDCBAEUTX7tjLUMdUAetfxk1y4Zt6YGXO3bv4k0En+Y+W7 qS2fbxGfom5x/Phh9iLYP/fralxKLEjGU48rNeI2oMsuzfNutaNI12kJsPnWPEpTjye7 E0iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=RxFCVzATMNQs9oNOrC7ndrU6qk8W9PwYsEwUkvOI508=; b=gusd0d4sdjYKQJNMaIZyxGIpjQLWeHIdthIvB/2KEm7hFhKDXLP5KstyXvT6wrhCvF S7EV3LZJ9CCMsx0IMiS8RewN8sQQXoraFsqxU2NcDF8JiiBUrVf0kyGr+JcYCgvj3HeU VyejCN9WX+kbcfBc3VBp+ynt/stjnjDtQsvRa0TqWwJmKpqT87pP2RMEHrDj+kbDqAXf jCPkEOK33Ts5DfdE/hMo48q0/iCfhJuz5oari0aoricds9BVA+8HBxMgsHjeSp/tZfva wwh2ut+xoteFJjdrcH9qJj8e+BYLmUdMHED/eDskVd61UdnATeffuwPxKSXLEp89TU15 WfdA== X-Gm-Message-State: AE9vXwNT2LE1vWl3qmTszOrSZ+lUDvm+JmQdinJbvGWcbNLQwWj7ovYm2neralQ9mCHIpQ== X-Received: by 10.194.112.98 with SMTP id ip2mr3398152wjb.95.1473862814111; Wed, 14 Sep 2016 07:20:14 -0700 (PDT) Received: from sixbynine.org (host-78-151-16-234.as13285.net. [78.151.16.234]) by smtp.gmail.com with ESMTPSA id m133sm11035007wmg.0.2016.09.14.07.20.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Sep 2016 07:20:13 -0700 (PDT) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Subject: [PATCH v5 03/11] drm/i915: return EACCES for check_cmd() failures Date: Wed, 14 Sep 2016 15:19:41 +0100 Message-Id: <20160914141949.27402-4-robert@sixbynine.org> X-Mailer: git-send-email 2.9.2 In-Reply-To: <20160914141949.27402-1-robert@sixbynine.org> References: <20160914141949.27402-1-robert@sixbynine.org> Cc: dri-devel@lists.freedesktop.org, Sourab Gupta , Daniel Vetter , Robert Bragg X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP check_cmd() is checking whether a command adheres to certain restrictions that ensure it's safe to execute within a privileged batch buffer. Returning false implies a privilege problem, not that the command is invalid. The distinction makes the difference between allowing the buffer to be executed as an unprivileged batch buffer or returning an EINVAL error to userspace without executing anything. In a case where userspace may want to test whether it can successfully write to a register that needs privileges the distinction may be important and an EINVAL error may be considered fatal. In particular this is currently true for Mesa, which includes a test for whether OACONTROL can be written too, but Mesa treats any error when flushing a batch buffer as fatal, calling exit(1). As it is currently Mesa can gracefully handle a failure to write to OACONTROL if the command parser is disabled, but if we were to remove OACONTROL from the parser's whitelist then the returned EINVAL would break Mesa applications as they attempt an OACONTROL write. Signed-off-by: Robert Bragg --- drivers/gpu/drm/i915/i915_cmd_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c index 7269fe8..5ad02dc 100644 --- a/drivers/gpu/drm/i915/i915_cmd_parser.c +++ b/drivers/gpu/drm/i915/i915_cmd_parser.c @@ -1272,7 +1272,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine, if (!check_cmd(engine, desc, cmd, length, is_master, &oacontrol_set)) { - ret = -EINVAL; + ret = -EACCES; break; }