From 44cfe94e4d7e7a58461bdbadd32734ba5054294a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=8B=E9=A1=B5?= <31466456+canyie@users.noreply.github.com> Date: Mon, 3 Oct 2022 23:26:33 +0800 Subject: [PATCH] Always cleanup init LD_PRELOAD hooks Fix #6296 --- native/src/init/preload.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/native/src/init/preload.c b/native/src/init/preload.c index 2751b366c..dde74d5d4 100644 --- a/native/src/init/preload.c +++ b/native/src/init/preload.c @@ -3,11 +3,14 @@ #include #include -int security_load_policy(void *data, size_t len) { +__attribute__((constructor)) +static void preload_init() { // Make sure our next exec won't get bugged unsetenv("LD_PRELOAD"); unlink("/dev/preload.so"); +} +int security_load_policy(void *data, size_t len) { int (*load_policy)(void *, size_t) = dlsym(RTLD_NEXT, "security_load_policy"); // Skip checking errors, because if we cannot find the symbol, there // isn't much we can do other than crashing anyways.