diff options
author | Adam Jackson <ajax@redhat.com> | 2018-10-10 14:09:11 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2018-10-12 11:35:42 -0400 |
commit | f5dc787fc9bb102e4eea477d1817e35370084ea2 (patch) | |
tree | bdfa227dd6ad4aef860add822c5dfed47e7ba2b5 | |
parent | 4795c069a503144ea31f01de0c039f32d9880292 (diff) |
fbdevhw: Refuse to touch PCI devices on the fallback probe path
Fixes: https://gitlab.freedesktop.org/xorg/driver/xf86-video-fbdev/issues/9
Signed-off-by: Adam Jackson <ajax@redhat.com>
(cherry picked from commit fc78bcca21e767697de6ad4d8e03b6728856f613)
-rw-r--r-- | hw/xfree86/fbdevhw/fbdevhw.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c index 0bd77df87..3fb1d2bba 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c @@ -329,6 +329,22 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) return -1; } + /* only touch non-PCI devices on this path */ + { + char buf[PATH_MAX]; + char *sysfs_path = NULL; + char *node = strrchr(dev, '/') + 1; + + if (asprintf(&sysfs_path, "/sys/class/graphics/%s", node) < 0 || + readlink(sysfs_path, buf, sizeof(buf) < 0) || + strstr(buf, "devices/pci")) { + free(sysfs_path); + close(fd); + return -1; + } + free(sysfs_path); + } + if (namep) { if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, (void *) (&fix))) { *namep = NULL; |