From 621fd0ee2938b180c6b87496904fec936c0d5782 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 24 Feb 2019 08:20:05 -0500 Subject: [PATCH] Fix SEGV_ACCERR on some 64 bit devices --- native/jni/utils/selinux.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/native/jni/utils/selinux.cpp b/native/jni/utils/selinux.cpp index d695f6fea..a075dc382 100644 --- a/native/jni/utils/selinux.cpp +++ b/native/jni/utils/selinux.cpp @@ -86,12 +86,12 @@ void dload_selinux() { void *handle = dlopen("libselinux.so", RTLD_LAZY); if (handle == nullptr) return; - *(void **) &freecon = dlsym(handle, "freecon"); - *(void **) &setcon = dlsym(handle, "setcon"); - *(void **) &getfilecon = dlsym(handle, "getfilecon"); - *(void **) &lgetfilecon = dlsym(handle, "lgetfilecon"); - *(void **) &setfilecon = dlsym(handle, "setfilecon"); - *(void **) &lsetfilecon = dlsym(handle, "lsetfilecon"); + /* We only use dlopen to know whether libselinux.so exists. + * For some reason calling symbols returned from dlsym + * will result to SEGV_ACCERR on some devices. + * Always use builtin implementations for SELinux stuffs. */ + dlclose(handle); + selinux_builtin_impl(); } static void restore_syscon(int dirfd) {