- This is a heavily modified version of susfs v1.5.12
- It does not comply with the upstream offical susfs v1.5.12
- sus_mount functionality still remain in v1.5.5 as backporting it to the latest version will result a mount detection leak in some apps/detectors
- Increase susfs_open_redirect UID limit to <11000
- susfs magic mount support is still implemented and enabled
- sus_map is implemented and complied with the upstream v1.5.12 codebase
This commit requires a bunch of backports commits from v4.19 and v5.x to make sus_map working:
0a8cbf3725edbacc5f1ead33eeae7e4d78823b5a proc: less memory for /proc/*/map_files readdir
37ae2444584654f6785f2cc49181f05af788c9b2 mm: smaps: split PSS into components
49a5115e11350ee68f6a5fbd56b3e817bf9e5aac fs/task_mmu: add pkeys header
6f94042bed51121f8f28a5e572cda20c21fed2e1 mm/pkeys: Add an empty arch_pkeys_enabled()
bbd5aec12b32097a71dc6a0097194a18f3ee9a17 mm/pkeys, powerpc, x86: Provide an empty vma_pkey() in linux/pkeys.h
849ca8ce954d9dbb082dcf83c98af861e98e5635 mm: /proc/pid/smaps_rollup: convert to single value seq_file
6071a482c8e603be25895cc2cac5f0eab61c4051 mm: /proc/pid/smaps: factor out common stats printing
03fd2fbe9c40da8128cec5c69ef54755c0f38c6c mm: /proc/pid/smaps: factor out mem stats gathering
95f8be4c8a86a491a1c2ac9bfe470aef9e1baa8f mm: /proc/pid/*maps remove is_pid and related wrappers
27956d255e3b012372951dd6131e07c106d2daae procfs: add seq_put_hex_ll to speed up /proc/pid/maps
7f2847d02cdc4491b5ee6d4a0043854cbd6c7a1a proc: add seq_put_decimal_ull_width to speed up /proc/pid/smaps
For KernelSU side patches for this commit you need the sidex15's KernelSU-Next fork:
https://github.com/sidex15/KernelSU-Next/tree/n3x7g3n-kernel
Or if you want to patch on your own here's the commit patch of susfs in the KernelSU-Next:
13b1dfd6e2
Co-authored-by: simonpunk <simonpunk2016@gmail.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
214 lines
6.5 KiB
C
214 lines
6.5 KiB
C
#ifndef KSU_SUSFS_H
|
|
#define KSU_SUSFS_H
|
|
|
|
#include <linux/version.h>
|
|
#include <linux/types.h>
|
|
#include <linux/utsname.h>
|
|
#include <linux/hashtable.h>
|
|
#include <linux/path.h>
|
|
#include <linux/susfs_def.h>
|
|
|
|
#define SUSFS_VERSION "v1.5.12"
|
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
|
|
#define SUSFS_VARIANT "NON-GKI"
|
|
#else
|
|
#define SUSFS_VARIANT "GKI"
|
|
#endif
|
|
|
|
/*********/
|
|
/* MACRO */
|
|
/*********/
|
|
#define getname_safe(name) (name == NULL ? ERR_PTR(-EINVAL) : getname(name))
|
|
#define putname_safe(name) (IS_ERR(name) ? NULL : putname(name))
|
|
|
|
/**********/
|
|
/* STRUCT */
|
|
/**********/
|
|
/* sus_path */
|
|
#ifdef CONFIG_KSU_SUSFS_SUS_PATH
|
|
struct st_susfs_sus_path {
|
|
unsigned long target_ino;
|
|
char target_pathname[SUSFS_MAX_LEN_PATHNAME];
|
|
unsigned int i_uid;
|
|
};
|
|
|
|
struct st_susfs_sus_path_list {
|
|
struct list_head list;
|
|
struct st_susfs_sus_path info;
|
|
char target_pathname[SUSFS_MAX_LEN_PATHNAME];
|
|
size_t path_len;
|
|
};
|
|
|
|
struct st_android_data_path {
|
|
char pathname[SUSFS_MAX_LEN_PATHNAME];
|
|
bool is_inited;
|
|
};
|
|
|
|
struct st_sdcard_path {
|
|
char pathname[SUSFS_MAX_LEN_PATHNAME];
|
|
bool is_inited;
|
|
};
|
|
#endif
|
|
|
|
/* sus_mount */
|
|
#ifdef CONFIG_KSU_SUSFS_SUS_MOUNT
|
|
struct st_susfs_sus_mount {
|
|
char target_pathname[SUSFS_MAX_LEN_PATHNAME];
|
|
unsigned long target_dev;
|
|
};
|
|
|
|
struct st_susfs_sus_mount_list {
|
|
struct list_head list;
|
|
struct st_susfs_sus_mount info;
|
|
};
|
|
#endif
|
|
|
|
/* sus_kstat */
|
|
#ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
|
|
struct st_susfs_sus_kstat {
|
|
int is_statically;
|
|
unsigned long target_ino; // the ino after bind mounted or overlayed
|
|
char target_pathname[SUSFS_MAX_LEN_PATHNAME];
|
|
unsigned long spoofed_ino;
|
|
unsigned long spoofed_dev;
|
|
unsigned int spoofed_nlink;
|
|
long long spoofed_size;
|
|
long spoofed_atime_tv_sec;
|
|
long spoofed_mtime_tv_sec;
|
|
long spoofed_ctime_tv_sec;
|
|
long spoofed_atime_tv_nsec;
|
|
long spoofed_mtime_tv_nsec;
|
|
long spoofed_ctime_tv_nsec;
|
|
unsigned long spoofed_blksize;
|
|
unsigned long long spoofed_blocks;
|
|
};
|
|
|
|
struct st_susfs_sus_kstat_hlist {
|
|
unsigned long target_ino;
|
|
struct st_susfs_sus_kstat info;
|
|
struct hlist_node node;
|
|
};
|
|
#endif
|
|
|
|
/* try_umount */
|
|
#ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
|
struct st_susfs_try_umount {
|
|
char target_pathname[SUSFS_MAX_LEN_PATHNAME];
|
|
int mnt_mode;
|
|
};
|
|
|
|
struct st_susfs_try_umount_list {
|
|
struct list_head list;
|
|
struct st_susfs_try_umount info;
|
|
};
|
|
#endif
|
|
|
|
/* spoof_uname */
|
|
#ifdef CONFIG_KSU_SUSFS_SPOOF_UNAME
|
|
struct st_susfs_uname {
|
|
char release[__NEW_UTS_LEN+1];
|
|
char version[__NEW_UTS_LEN+1];
|
|
};
|
|
#endif
|
|
|
|
/* open_redirect */
|
|
#ifdef CONFIG_KSU_SUSFS_OPEN_REDIRECT
|
|
struct st_susfs_open_redirect {
|
|
unsigned long target_ino;
|
|
char target_pathname[SUSFS_MAX_LEN_PATHNAME];
|
|
char redirected_pathname[SUSFS_MAX_LEN_PATHNAME];
|
|
};
|
|
|
|
struct st_susfs_open_redirect_hlist {
|
|
unsigned long target_ino;
|
|
char target_pathname[SUSFS_MAX_LEN_PATHNAME];
|
|
char redirected_pathname[SUSFS_MAX_LEN_PATHNAME];
|
|
struct hlist_node node;
|
|
};
|
|
#endif
|
|
|
|
/* sus_su */
|
|
#ifdef CONFIG_KSU_SUSFS_SUS_SU
|
|
struct st_sus_su {
|
|
int mode;
|
|
};
|
|
#endif
|
|
|
|
/* sus_map */
|
|
#ifdef CONFIG_KSU_SUSFS_SUS_MAP
|
|
struct st_susfs_sus_map {
|
|
char target_pathname[SUSFS_MAX_LEN_PATHNAME];
|
|
};
|
|
#endif
|
|
|
|
/***********************/
|
|
/* FORWARD DECLARATION */
|
|
/***********************/
|
|
/* sus_path */
|
|
#ifdef CONFIG_KSU_SUSFS_SUS_PATH
|
|
int susfs_set_i_state_on_external_dir(char __user* user_info, int cmd);
|
|
int susfs_add_sus_path(struct st_susfs_sus_path* __user user_info);
|
|
#endif
|
|
/* sus_mount */
|
|
#ifdef CONFIG_KSU_SUSFS_SUS_MOUNT
|
|
int susfs_add_sus_mount(struct st_susfs_sus_mount* __user user_info);
|
|
#ifdef CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT
|
|
int susfs_auto_add_sus_bind_mount(const char *pathname, struct path *path_target);
|
|
#endif // #ifdef CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT
|
|
#ifdef CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT
|
|
void susfs_auto_add_sus_ksu_default_mount(const char __user *to_pathname);
|
|
#endif // #ifdef CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT
|
|
#endif // #ifdef CONFIG_KSU_SUSFS_SUS_MOUNT
|
|
|
|
/* sus_kstat */
|
|
#ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
|
|
int susfs_add_sus_kstat(struct st_susfs_sus_kstat* __user user_info);
|
|
int susfs_update_sus_kstat(struct st_susfs_sus_kstat* __user user_info);
|
|
void susfs_sus_ino_for_generic_fillattr(unsigned long ino, struct kstat *stat);
|
|
void susfs_sus_ino_for_show_map_vma(unsigned long ino, dev_t *out_dev, unsigned long *out_ino);
|
|
#endif
|
|
/* try_umount */
|
|
#ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
|
int susfs_add_try_umount(struct st_susfs_try_umount* __user user_info);
|
|
void susfs_try_umount(uid_t target_uid);
|
|
#ifdef CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT
|
|
void susfs_auto_add_try_umount_for_bind_mount(struct path *path);
|
|
#endif // #ifdef CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT
|
|
#endif // #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
|
/* spoof_uname */
|
|
#ifdef CONFIG_KSU_SUSFS_SPOOF_UNAME
|
|
int susfs_set_uname(struct st_susfs_uname* __user user_info);
|
|
void susfs_spoof_uname(struct new_utsname* tmp);
|
|
#endif
|
|
/* set_log */
|
|
#ifdef CONFIG_KSU_SUSFS_ENABLE_LOG
|
|
void susfs_set_log(bool enabled);
|
|
#endif
|
|
/* spoof_cmdline_or_bootconfig */
|
|
#ifdef CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG
|
|
int susfs_set_cmdline_or_bootconfig(char* __user user_fake_boot_config);
|
|
int susfs_spoof_cmdline_or_bootconfig(struct seq_file *m);
|
|
#endif
|
|
/* open_redirect */
|
|
#ifdef CONFIG_KSU_SUSFS_OPEN_REDIRECT
|
|
int susfs_add_open_redirect(struct st_susfs_open_redirect* __user user_info);
|
|
struct filename* susfs_get_redirected_path(unsigned long ino);
|
|
#endif
|
|
/* sus_su */
|
|
#ifdef CONFIG_KSU_SUSFS_SUS_SU
|
|
int susfs_get_sus_su_working_mode(void);
|
|
int susfs_sus_su(struct st_sus_su* __user user_info);
|
|
#endif
|
|
/* sus_map */
|
|
#ifdef CONFIG_KSU_SUSFS_SUS_MAP
|
|
int susfs_add_sus_map(struct st_susfs_sus_map* __user user_info);
|
|
#endif
|
|
|
|
int susfs_get_enabled_features(char __user* buf, size_t bufsize);
|
|
void susfs_set_avc_log_spoofing(bool enabled);
|
|
|
|
/* susfs_init */
|
|
void susfs_init(void);
|
|
|
|
#endif
|