From 4429bdd7f5a2e4610d3a8677cfbd3e7e2712751e Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Fri, 21 Oct 2022 15:34:06 -0700 Subject: [PATCH] drm-shim: Use hide_drm_device_path() to hide other drm devices Signed-off-by: Jordan Justen Reviewed-by: Lionel Landwerlin Reviewed-by: Eric Engestrom Part-of: --- src/drm-shim/drm_shim.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/drm-shim/drm_shim.c b/src/drm-shim/drm_shim.c index ba00d95e1b6..f59bb6ed10d 100644 --- a/src/drm-shim/drm_shim.c +++ b/src/drm-shim/drm_shim.c @@ -324,6 +324,11 @@ PUBLIC int open(const char *path, int flags, ...) mode_t mode = va_arg(ap, mode_t); va_end(ap); + if (hide_drm_device_path(path)) { + errno = ENOENT; + return -1; + } + if (strcmp(path, render_node_path) != 0) return real_open(path, flags, mode); @@ -363,6 +368,11 @@ PUBLIC int __xstat(int ver, const char *path, struct stat *st) if (render_node_minor == -1) return real___xstat(ver, path, st); + if (hide_drm_device_path(path)) { + errno = ENOENT; + return -1; + } + /* Fool libdrm's probe of whether the /sys dir for this char dev is * there. */ @@ -397,6 +407,11 @@ PUBLIC int __xstat64(int ver, const char *path, struct stat64 *st) if (render_node_minor == -1) return real___xstat64(ver, path, st); + if (hide_drm_device_path(path)) { + errno = ENOENT; + return -1; + } + /* Fool libdrm's probe of whether the /sys dir for this char dev is * there. */ @@ -465,6 +480,11 @@ PUBLIC int stat(const char* path, struct stat* stat_buf) if (render_node_minor == -1) return real_stat(path, stat_buf); + if (hide_drm_device_path(path)) { + errno = ENOENT; + return -1; + } + /* Fool libdrm's probe of whether the /sys dir for this char dev is * there. */ @@ -498,6 +518,11 @@ PUBLIC int stat64(const char* path, struct stat64* stat_buf) if (render_node_minor == -1) return real_stat64(path, stat_buf); + if (hide_drm_device_path(path)) { + errno = ENOENT; + return -1; + } + /* Fool libdrm's probe of whether the /sys dir for this char dev is * there. */ @@ -654,6 +679,11 @@ readlink(const char *path, char *buf, size_t size) { init_shim(); + if (hide_drm_device_path(path)) { + errno = ENOENT; + return -1; + } + if (strcmp(path, subsystem_path) != 0) return real_readlink(path, buf, size);