From 7ab1cdac9013d2a4c41b3d0975f953585517cfa1 Mon Sep 17 00:00:00 2001 From: Tobias Jakobi Date: Mon, 25 Dec 2023 00:21:44 +0100 Subject: [PATCH] xf86drm: ignore symlinks in process_device() If the user has some UDev rules in place that creates symlinks for one of the card or render nodes, and the name of the symlink is too long, then drmDeviceAlloc() ends up truncating the name of the node. This in turn results in chaos in different subsystems. E.g. vulkaninfo dies early with this: Code 0 : failed to stat DRM primary node /dev/dri/my-favorite- (VK_ERROR_INITIALIZATION_FAILED) (if the symlink is called /dev/dri/my-favorite-card-node) Signed-off-by: Tobias Jakobi --- xf86drm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xf86drm.c b/xf86drm.c index 2e76f0ea..150c6095 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -4479,7 +4479,10 @@ process_device(drmDevicePtr *device, const char *d_name, return -1; snprintf(node, PATH_MAX, "%s/%s", DRM_DIR_NAME, d_name); - if (stat(node, &sbuf)) + if (lstat(node, &sbuf)) + return -1; + + if (S_ISLNK(sbuf.st_mode)) return -1; maj = major(sbuf.st_rdev);