Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

Commit d2cb14f

Browse files
authored
fix: stat log spam (#18)
This commit fixes the issue that due to early execution of dex2oatd, it would lead to us try to access folders that only exist post-decryption, which takes a while, and before that caused a log spam.
1 parent 9cf8e30 commit d2cb14f

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

daemon/src/main/jni/denylist.cpp

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,29 @@ bool apatch_uid_should_umount(const char *const process) {
397397
return false;
398398
}
399399

400+
int get_stat(const char* app_name, struct stat* st) {
401+
// ignore sandbox package
402+
if (strcmp("com.android.sdksandbox", app_name) == 0 ||
403+
strcmp("com.google.android.sdksandbox", app_name) == 0) {
404+
return -1;
405+
}
406+
407+
char app_data_dir[PATH_MAX];
408+
snprintf(app_data_dir, sizeof(app_data_dir), "/data/data/%s", app_name);
409+
410+
if (stat(app_data_dir, st) == -1) {
411+
snprintf(app_data_dir, sizeof(app_data_dir), "/data/user_de/0/%s", app_name);
412+
413+
if (stat(app_data_dir, st) == -1) {
414+
PLOGE("Failed to stat /data/data/%s and /data/user_de/0/%s", app_name, app_name);
415+
416+
return -1;
417+
}
418+
}
419+
420+
return 0;
421+
}
422+
400423
extern "C" JNIEXPORT jboolean JNICALL
401424
Java_org_lsposed_lspd_service_DenylistManager_isInDenylist(JNIEnv *env, jclass, jstring appName) {
402425
const char *app_name = env->GetStringUTFChars(appName, nullptr);
@@ -406,23 +429,16 @@ Java_org_lsposed_lspd_service_DenylistManager_isInDenylist(JNIEnv *env, jclass,
406429
return JNI_FALSE;
407430
}
408431

409-
char app_data_dir[PATH_MAX];
410-
snprintf(app_data_dir, sizeof(app_data_dir), "/data/data/%s", app_name);
411-
412-
struct stat st;
413-
if (stat(app_data_dir, &st) == -1) {
414-
PLOGE("Failed to stat %s", app_data_dir);
415-
416-
goto app_not_in_denylist;
417-
}
418-
419432
if (root_impl == -1 && !ksu_get_existence() && !magisk_get_existence() && !apatch_get_existence()) {
420433
LOGE("No supported root implementation found, skipping denylist check");
421434

422435
goto app_not_in_denylist;
423436
}
424437

425438
if (root_impl == 1) {
439+
struct stat st;
440+
if (get_stat(app_name, &st) == -1) goto app_not_in_denylist;
441+
426442
if (ksu_is_in_denylist(st.st_uid)) {
427443
LOGI("App %s is in KernelSU denylist", app_name);
428444

@@ -486,23 +502,16 @@ Java_org_lsposed_lspd_service_DenylistManager_isInDenylistFromClasspathDir(JNIEn
486502
}
487503
env->ReleaseStringUTFChars(classpathDirArg, classpath_dir_arg);
488504

489-
char app_data_dir[1024] = {0};
490-
snprintf(app_data_dir, sizeof(app_data_dir), "/data/data/%s", app_name);
491-
492-
struct stat st;
493-
if (stat(app_data_dir, &st) == -1) {
494-
PLOGE("Failed to stat %s", app_data_dir);
495-
496-
goto app_not_in_denylist;
497-
}
498-
499505
if (root_impl == -1 && !ksu_get_existence() && !magisk_get_existence() && !apatch_get_existence()) {
500506
LOGE("No supported root implementation found, skipping denylist check");
501507

502508
goto app_not_in_denylist;
503509
}
504510

505511
if (root_impl == 1) {
512+
struct stat st;
513+
if (get_stat(app_name, &st) == -1) goto app_not_in_denylist;
514+
506515
if (ksu_is_in_denylist(st.st_uid)) {
507516
LOGI("App %s is in KernelSU denylist", app_name);
508517

0 commit comments

Comments
 (0)