Skip to content

Commit 1e65ee0

Browse files
backslashxxnullptr03
authored andcommitted
drivers: kernelsu: 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. 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 (tiann/KernelSU#2626)" - upstream tiann/KernelSU@0b6998b Signed-off-by: backslashxx <[email protected]> Signed-off-by: Tashfin Shakeer Rhythm <[email protected]>
1 parent 429ed8b commit 1e65ee0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/kernelsu/throne_tracker.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,24 @@ void search_manager(const char *path, int depth, struct list_head *uid_data)
258258
goto skip_iterate;
259259
}
260260

261+
// grab magic on first folder, which is /data/app
262+
if (!data_app_magic) {
263+
if (file->f_inode->i_sb->s_magic) {
264+
data_app_magic = file->f_inode->i_sb->s_magic;
265+
pr_info("%s: dir: %s got magic! 0x%lx\n", __func__, pos->dirpath, data_app_magic);
266+
} else {
267+
filp_close(file, NULL);
268+
goto skip_iterate;
269+
}
270+
}
271+
272+
if (file->f_inode->i_sb->s_magic != data_app_magic) {
273+
pr_info("%s: skip: %s magic: 0x%lx expected: 0x%lx\n", __func__, pos->dirpath,
274+
file->f_inode->i_sb->s_magic, data_app_magic);
275+
filp_close(file, NULL);
276+
goto skip_iterate;
277+
}
278+
261279
iterate_dir(file, &ctx.ctx);
262280
filp_close(file, NULL);
263281
}

0 commit comments

Comments
 (0)