Skip to content

Commit ef5a3fd

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 4ce1295 commit ef5a3fd

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
@@ -316,6 +316,24 @@ void search_manager(const char *path, int depth, struct list_head *uid_data)
316316
goto skip_iterate;
317317
}
318318

319+
// grab magic on first folder, which is /data/app
320+
if (!data_app_magic) {
321+
if (file->f_inode->i_sb->s_magic) {
322+
data_app_magic = file->f_inode->i_sb->s_magic;
323+
pr_info("%s: dir: %s got magic! 0x%lx\n", __func__, pos->dirpath, data_app_magic);
324+
} else {
325+
filp_close(file, NULL);
326+
goto skip_iterate;
327+
}
328+
}
329+
330+
if (file->f_inode->i_sb->s_magic != data_app_magic) {
331+
pr_info("%s: skip: %s magic: 0x%lx expected: 0x%lx\n", __func__, pos->dirpath,
332+
file->f_inode->i_sb->s_magic, data_app_magic);
333+
filp_close(file, NULL);
334+
goto skip_iterate;
335+
}
336+
319337
iterate_dir(file, &ctx.ctx);
320338
filp_close(file, NULL);
321339
}

0 commit comments

Comments
 (0)