fix(preload): apps that reload libudev no longer crash in the input wrappers (#3180)

fix(preload): keep libudev loaded while the input wrappers use it

Programs that close libudev and open it again crashed in the next wrapped
udev call: the wrappers kept function pointers into the unmapped copy.
Pin libudev with RTLD_NODELETE when it is opened so those pointers and
the stored handle stay valid.
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-24 20:19:53 -05:00
1 parent 906e66e3cf
commit 238ef76c5c
3 files changed
+45 -5

No files matched your search

+3 -2
View File
@@ -100,7 +100,8 @@ static long path_statx(int dirfd, const char *path, int flags, unsigned int mask
return next_statx(dirfd, path, flags, mask, out);
}
void bl_inputudev_note_dlopen(const char *path, void *handle) __attribute__((weak, visibility("hidden")));
void bl_inputudev_note_dlopen(const char *path, void *handle, void *(*open)(const char *, int))
__attribute__((weak, visibility("hidden")));
void *dlopen(const char *filename, int flags) {
void *handle;
@@ -114,7 +115,7 @@ void *dlopen(const char *filename, int flags) {
flags &= ~RTLD_DEEPBIND;
}
handle = real_dlopen != NULL ? real_dlopen(filename, flags) : NULL;
if (handle != NULL && bl_inputudev_note_dlopen != NULL) bl_inputudev_note_dlopen(filename, handle);
if (handle != NULL && bl_inputudev_note_dlopen != NULL) bl_inputudev_note_dlopen(filename, handle, real_dlopen);
return handle;
}