kernel: throne_tracker: avoid cross-fs traversal using s_magic check (#2633)
Skip directories that does NOT have the same magic as /data/app.
This is to avoid scanning incfs and any other stacked filesystems.
While this is way dumber, it's way cheaper.
no kern_path(), no missable path_put(), no ref handling.
This supercedes
`throne_tracker: avoid cross fs access
(https://github.com/tiann/KernelSU/pull/2626)`
- upstream
0b6998b474
Signed-off-by: backslashxx
<118538522+backslashxx@users.noreply.github.com>
This commit is contained in:
@@ -217,6 +217,7 @@ void search_manager(const char *path, int depth, struct list_head *uid_data)
|
|||||||
int i, stop = 0;
|
int i, stop = 0;
|
||||||
struct list_head data_path_list;
|
struct list_head data_path_list;
|
||||||
INIT_LIST_HEAD(&data_path_list);
|
INIT_LIST_HEAD(&data_path_list);
|
||||||
|
unsigned long data_app_magic = 0;
|
||||||
|
|
||||||
// Initialize APK cache list
|
// Initialize APK cache list
|
||||||
struct apk_path_hash *pos, *n;
|
struct apk_path_hash *pos, *n;
|
||||||
@@ -249,6 +250,24 @@ void search_manager(const char *path, int depth, struct list_head *uid_data)
|
|||||||
goto skip_iterate;
|
goto skip_iterate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// grab magic on first folder, which is /data/app
|
||||||
|
if (!data_app_magic) {
|
||||||
|
if (file->f_inode->i_sb->s_magic) {
|
||||||
|
data_app_magic = file->f_inode->i_sb->s_magic;
|
||||||
|
pr_info("%s: dir: %s got magic! 0x%lx\n", __func__, pos->dirpath, data_app_magic);
|
||||||
|
} else {
|
||||||
|
filp_close(file, NULL);
|
||||||
|
goto skip_iterate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file->f_inode->i_sb->s_magic != data_app_magic) {
|
||||||
|
pr_info("%s: skip: %s magic: 0x%lx expected: 0x%lx\n", __func__, pos->dirpath,
|
||||||
|
file->f_inode->i_sb->s_magic, data_app_magic);
|
||||||
|
filp_close(file, NULL);
|
||||||
|
goto skip_iterate;
|
||||||
|
}
|
||||||
|
|
||||||
iterate_dir(file, &ctx.ctx);
|
iterate_dir(file, &ctx.ctx);
|
||||||
filp_close(file, NULL);
|
filp_close(file, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user