Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 677140 - x11-base/xorg-server-1.20.3: modeset(0): drmSetMaster failed: Permission denied
Summary: x11-base/xorg-server-1.20.3: modeset(0): drmSetMaster failed: Permission denied
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo X packagers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-03 06:31 UTC by Sergey 'L29Ah' Alirzaev
Modified: 2019-03-05 17:21 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey 'L29Ah' Alirzaev 2019-02-03 06:31:57 UTC
Not sure if it's about X or the kernel actually.

I've moved my system to a Skylake-based laptop and cannot use the modesetting driver on it, with both USE={-,}suid: Xorg producing this error in the log:
[  1392.088] (EE) modeset(0): drmSetMaster failed: Permission denied

strace shows that it is able to open the drm device file, but then fails at ioctl:
[pid  4441] ioctl(10, DRM_IOCTL_SET_MASTER, 0) = -1 EACCES (Permission denied)

Googling have only hinted me that DRM_IOCTL_SET_MASTER is only accessible to root on vanilla kernels, although this may be old info: https://groups.google.com/a/chromium.org/forum/#!topic/chromium-os-reviews/MkLntCYRP-g

I've also tried X with Intel DDX: X starts, but then Mesa silently decides to use llvmpipe instead of the hardware-accelerated OpenGL implementation.

I run X through qingy's xsession option, but get essentially same results with `startx -- vt1`.
Comment 1 Sergey 'L29Ah' Alirzaev 2019-02-06 14:00:01 UTC
Worked around by `chmod u+s /usr/libexec/Xorg`.
Comment 2 Chí-Thanh Christopher Nguyễn gentoo-dev 2019-02-06 19:38:58 UTC
Does your kernel have CONFIG_TMPFS_POSIX_ACL enabled?
Comment 3 Sergey 'L29Ah' Alirzaev 2019-02-07 06:19:00 UTC
(In reply to Chí-Thanh Christopher Nguyễn from comment #2)
> Does your kernel have CONFIG_TMPFS_POSIX_ACL enabled?

Yes.
Comment 4 Piotr Karbowski (RETIRED) gentoo-dev 2019-03-04 06:34:34 UTC
Hi

to use DRM SETMASTER you need to either have suid bit on your /usr/bin/Xorg, CAP_SYS_ADMIN or xorg-server built with logind support (systemd USE flag as for now).

Please share your xorg-server USE flags, information if you run systemd and file mode of /usr/bin/Xorg

You can also chcek if running `setcap cap_sys_admin+ep /usr/bin/Xorg` helps in your case.
Comment 5 Sergey 'L29Ah' Alirzaev 2019-03-05 05:00:45 UTC
(In reply to Piotr Karbowski from comment #4)
> Please share your xorg-server USE flags, information if you run systemd and
> file mode of /usr/bin/Xorg

     Installed versions:  1.20.4(0/1.20.4)(08:18:35 2019-03-02)(glamor ipv6 kdrive suid udev xcsecurity xephyr xorg xvfb -debug -dmx -doc -libressl -minimal -selinux -static-libs -systemd -unwind -wayland -xnest)
No systemd.
-rwxr-xr-x 1 root root 273 Mar  2 08:18 /usr/bin/Xorg
Comment 6 Sergey 'L29Ah' Alirzaev 2019-03-05 05:02:39 UTC
(In reply to Piotr Karbowski from comment #4)
> You can also chcek if running `setcap cap_sys_admin+ep /usr/bin/Xorg` helps
> in your case.

It doesn't.
Comment 7 Matt Turner gentoo-dev 2019-03-05 06:09:10 UTC
(In reply to Sergey 'L29Ah' Alirzaev from comment #5)
> (In reply to Piotr Karbowski from comment #4)
> > Please share your xorg-server USE flags, information if you run systemd and
> > file mode of /usr/bin/Xorg
> 
>      Installed versions:  1.20.4(0/1.20.4)(08:18:35 2019-03-02)(glamor ipv6
> kdrive suid udev xcsecurity xephyr xorg xvfb -debug -dmx -doc -libressl
> -minimal -selinux -static-libs -systemd -unwind -wayland -xnest)
> No systemd.
> -rwxr-xr-x 1 root root 273 Mar  2 08:18 /usr/bin/Xorg

I don't understand how that can be. With USE="suid -systemd" I get

-rwsr-xr-x 1 root root 2.3M Mar  4 22:06 /usr/bin/Xorg

whereas your binary doesn't have suid set. Is something on your system dropping the suid bit? Does some file system not support suid?

(In reply to Sergey 'L29Ah' Alirzaev from comment #1)
> Worked around by `chmod u+s /usr/libexec/Xorg`.

Also strange, since you shouldn't have a /usr/libexec/Xorg if you are building without systemd.
Comment 8 Matt Turner gentoo-dev 2019-03-05 06:34:24 UTC
(In reply to Sergey 'L29Ah' Alirzaev from comment #5)
> (In reply to Piotr Karbowski from comment #4)
> > Please share your xorg-server USE flags, information if you run systemd and
> > file mode of /usr/bin/Xorg
> 
>      Installed versions:  1.20.4(0/1.20.4)(08:18:35 2019-03-02)(glamor ipv6
> kdrive suid udev xcsecurity xephyr xorg xvfb -debug -dmx -doc -libressl
> -minimal -selinux -static-libs -systemd -unwind -wayland -xnest)
> No systemd.
> -rwxr-xr-x 1 root root 273 Mar  2 08:18 /usr/bin/Xorg

273 bytes is the size of the Xorg suid wrapper. It's installed as /usr/bin/Xorg if USE="suid systemd"

I cannot reproduce what your report with your USE flags, but I can if I use your USE flags but with +systemd (in which case /usr/libexec/Xorg.wrap has suid).

Please attach a build log of xorg-server.
Comment 9 Sergey 'L29Ah' Alirzaev 2019-03-05 07:24:05 UTC
(In reply to Matt Turner from comment #7)
> I don't understand how that can be. With USE="suid -systemd" I get
> 
> -rwsr-xr-x 1 root root 2.3M Mar  4 22:06 /usr/bin/Xorg
> 
> whereas your binary doesn't have suid set. Is something on your system
> dropping the suid bit? Does some file system not support suid?

Nah, it's a regular ext4 without any fancy flags.
Comment 10 Sergey 'L29Ah' Alirzaev 2019-03-05 07:44:49 UTC
(In reply to Matt Turner from comment #8)
> 273 bytes is the size of the Xorg suid wrapper. It's installed as
> /usr/bin/Xorg if USE="suid systemd"
> 
> I cannot reproduce what your report with your USE flags, but I can if I use
> your USE flags but with +systemd (in which case /usr/libexec/Xorg.wrap has
> suid).
> 
> Please attach a build log of xorg-server.

Okay, i found out i had the ebuild modified using sed since the systemd flag introduction that enabled suid unconditionally since https://bugs.gentoo.org/669648#c8, and it messed up:

-               $(usex suid $(use_enable systemd suid-wrapper) '--disable-suid-wrapper')
-               $(usex suid $(use_enable !systemd install-setuid) '--disable-install-setuid')
+               $(usex suid --enable-suid-wrapper '--disable-suid-wrapper')
+               $(usex suid --disable-install-setuid '--disable-install-setuid')

It worked just fine on ivy bridge, but it seems like on kaby lake the kernel decided only a privileged user can use drm. What?!

USE=suid works as expected since i reverted the patch.
Comment 11 Piotr Karbowski (RETIRED) gentoo-dev 2019-03-05 08:26:43 UTC
The code that handle it in kernel did not changed recently, and if your Ivy Bridge were using either the intel driver or modesetting driver over KMS it would require the extra privileges to take control over framebuffer. Perhaps you do have suid on Xorg or suid-enabled suidwrapper there.
Comment 12 Matt Turner gentoo-dev 2019-03-05 17:21:21 UTC
Okay, that makes more sense.