Skip to content

Commit c93c10e

Browse files
committed
throne_tracker: avoid cross-fs traversal using s_magic check
Skip directories that does NOT have the same magic as /data/app. This is to avoid scanning incfs and any other stacked filesystems. This is a workaround for Ultra-Legacy kernels where upstream's method fails. Replaces: `throne_tracker: avoid cross fs access` tiann/KernelSU#2626 Signed-off-by: backslashxx <[email protected]>
1 parent 70379a2 commit c93c10e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/kernelsu/throne_tracker.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ void search_manager(const char *path, int depth, struct list_head *uid_data)
225225
int i, stop = 0;
226226
struct list_head data_path_list;
227227
INIT_LIST_HEAD(&data_path_list);
228+
unsigned long data_app_magic = 0;
228229

229230
// Initialize APK cache list
230231
struct apk_path_hash *pos, *n;
@@ -271,6 +272,22 @@ void search_manager(const char *path, int depth, struct list_head *uid_data)
271272
pr_err("Failed to open directory: %s, err: %ld\n", pos->dirpath, PTR_ERR(file));
272273
goto skip_iterate;
273274
}
275+
276+
// grab magic on first folder, which is /data/app
277+
if (!data_app_magic) {
278+
if (file->f_inode->i_sb->s_magic) {
279+
data_app_magic = file->f_inode->i_sb->s_magic;
280+
pr_info("%s: dir: %s got magic! %lx\n", __func__, pos->dirpath, data_app_magic);
281+
} else
282+
goto skip_iterate;
283+
}
284+
285+
if (file->f_inode->i_sb->s_magic != data_app_magic) {
286+
pr_info("%s: skip: %s magic: %lx expected: %lx\n", __func__, pos->dirpath,
287+
file->f_inode->i_sb->s_magic, data_app_magic);
288+
filp_close(file, NULL);
289+
goto skip_iterate;
290+
}
274291

275292
iterate_dir(file, &ctx.ctx);
276293
filp_close(file, NULL);

0 commit comments

Comments
 (0)