]> git.itanic.dy.fi Git - linux-stable/commit
drm/i915: return EACCES for check_cmd() failures
authorRobert Bragg <robert@sixbynine.org>
Mon, 7 Nov 2016 19:49:49 +0000 (19:49 +0000)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 22 Nov 2016 13:31:28 +0000 (14:31 +0100)
commit9bbeaedb664a6d3e1cfbe6b0c2f07bf667512456
tree8209f7708125e9c43f4a653644d47da32480668d
parenta941795a3aead3765d6f9e12dc1828fe06ba3d5d
drm/i915: return EACCES for check_cmd() failures

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.

This bumps the command parser version from 7 to 8, as the change is
visible to userspace.

Signed-off-by: Robert Bragg <robert@sixbynine.org>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Sourab Gupta <sourab.gupta@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161107194957.3385-4-robert@sixbynine.org
drivers/gpu/drm/i915/i915_cmd_parser.c