Fix SEGV_ACCERR on some 64 bit devices

This commit is contained in:
topjohnwu 2019-02-24 08:20:05 -05:00
parent 6ca8db2f0c
commit 621fd0ee29

View File

@ -86,12 +86,12 @@ void dload_selinux() {
void *handle = dlopen("libselinux.so", RTLD_LAZY); void *handle = dlopen("libselinux.so", RTLD_LAZY);
if (handle == nullptr) if (handle == nullptr)
return; return;
*(void **) &freecon = dlsym(handle, "freecon"); /* We only use dlopen to know whether libselinux.so exists.
*(void **) &setcon = dlsym(handle, "setcon"); * For some reason calling symbols returned from dlsym
*(void **) &getfilecon = dlsym(handle, "getfilecon"); * will result to SEGV_ACCERR on some devices.
*(void **) &lgetfilecon = dlsym(handle, "lgetfilecon"); * Always use builtin implementations for SELinux stuffs. */
*(void **) &setfilecon = dlsym(handle, "setfilecon"); dlclose(handle);
*(void **) &lsetfilecon = dlsym(handle, "lsetfilecon"); selinux_builtin_impl();
} }
static void restore_syscon(int dirfd) { static void restore_syscon(int dirfd) {