Skip to content

Commit

Permalink
fs/proc: hide magisk mounts for IsolatedService
Browse files Browse the repository at this point in the history
The issue described here:
https://darvincitech.wordpress.com/2019/11/04/detecting-magisk-hide/

Signed-off-by: Denis Efremov <[email protected]>
  • Loading branch information
evdenis authored and DozNaka committed Aug 5, 2022
1 parent dddeca0 commit 7206878
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions fs/proc_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ static void show_type(struct seq_file *m, struct super_block *sb)
}
}

static inline int skip_magisk_entry(const char *devname)
{
if (devname && strstr(devname, "magisk")) {
char name[TASK_COMM_LEN];
get_task_comm(name, current);
if (strstr(name, "Binder") ||
strstr(name, "JavaBridge")) {
return SEQ_SKIP;
}
}
return 0;
}

static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt)
{
struct proc_mounts *p = m->private;
Expand All @@ -107,6 +120,9 @@ static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt)
if (err)
goto out;
} else {
err = skip_magisk_entry(r->mnt_devname);
if (err)
goto out;
mangle(m, r->mnt_devname ? r->mnt_devname : "none");
}
seq_putc(m, ' ');
Expand Down Expand Up @@ -145,6 +161,9 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt)
if (err)
goto out;
} else {
err = skip_magisk_entry(r->mnt_devname);
if (err)
goto out;
seq_dentry(m, mnt->mnt_root, " \t\n\\");
}
seq_putc(m, ' ');
Expand Down Expand Up @@ -209,6 +228,9 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt)
if (err)
goto out;
} else {
err = skip_magisk_entry(r->mnt_devname);
if (err)
goto out;
if (r->mnt_devname) {
seq_puts(m, "device ");
mangle(m, r->mnt_devname);
Expand Down

0 comments on commit 7206878

Please sign in to comment.