kernel: add CMD_GET_SUSFS_FEATURE_STATUS command to get the correct functional state of SUSFS
This commit is contained in:
@@ -522,6 +522,8 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Check if kpm is enabled
|
||||||
if (arg2 == CMD_ENABLE_KPM) {
|
if (arg2 == CMD_ENABLE_KPM) {
|
||||||
bool KPM_Enabled = IS_ENABLED(CONFIG_KPM);
|
bool KPM_Enabled = IS_ENABLED(CONFIG_KPM);
|
||||||
if (copy_to_user((void __user *)arg3, &KPM_Enabled, sizeof(KPM_Enabled)))
|
if (copy_to_user((void __user *)arg3, &KPM_Enabled, sizeof(KPM_Enabled)))
|
||||||
@@ -529,6 +531,7 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checking hook usage
|
||||||
if (arg2 == CMD_HOOK_TYPE) {
|
if (arg2 == CMD_HOOK_TYPE) {
|
||||||
const char *hook_type;
|
const char *hook_type;
|
||||||
|
|
||||||
@@ -552,6 +555,119 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get SUSFS function status
|
||||||
|
if (arg2 == CMD_GET_SUSFS_FEATURE_STATUS) {
|
||||||
|
struct susfs_feature_status status;
|
||||||
|
|
||||||
|
memset(&status, 0, sizeof(status));
|
||||||
|
|
||||||
|
if (!ksu_access_ok((void __user*)arg3, sizeof(status))) {
|
||||||
|
pr_err("susfs_feature_status: arg3 is not accessible\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_SUS_PATH
|
||||||
|
status.status_sus_path = true;
|
||||||
|
#else
|
||||||
|
status.status_sus_path = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_SUS_MOUNT
|
||||||
|
status.status_sus_mount = true;
|
||||||
|
#else
|
||||||
|
status.status_sus_mount = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT
|
||||||
|
status.status_auto_default_mount = true;
|
||||||
|
#else
|
||||||
|
status.status_auto_default_mount = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT
|
||||||
|
status.status_auto_bind_mount = true;
|
||||||
|
#else
|
||||||
|
status.status_auto_bind_mount = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
|
||||||
|
status.status_sus_kstat = true;
|
||||||
|
#else
|
||||||
|
status.status_sus_kstat = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
||||||
|
status.status_try_umount = true;
|
||||||
|
#else
|
||||||
|
status.status_try_umount = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT
|
||||||
|
status.status_auto_try_umount_bind = true;
|
||||||
|
#else
|
||||||
|
status.status_auto_try_umount_bind = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_SPOOF_UNAME
|
||||||
|
status.status_spoof_uname = true;
|
||||||
|
#else
|
||||||
|
status.status_spoof_uname = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_ENABLE_LOG
|
||||||
|
status.status_enable_log = true;
|
||||||
|
#else
|
||||||
|
status.status_enable_log = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS
|
||||||
|
status.status_hide_symbols = true;
|
||||||
|
#else
|
||||||
|
status.status_hide_symbols = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG
|
||||||
|
status.status_spoof_cmdline = true;
|
||||||
|
#else
|
||||||
|
status.status_spoof_cmdline = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_OPEN_REDIRECT
|
||||||
|
status.status_open_redirect = true;
|
||||||
|
#else
|
||||||
|
status.status_open_redirect = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT
|
||||||
|
status.status_magic_mount = true;
|
||||||
|
#else
|
||||||
|
status.status_magic_mount = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_SUS_OVERLAYFS
|
||||||
|
status.status_overlayfs_auto_kstat = true;
|
||||||
|
#else
|
||||||
|
status.status_overlayfs_auto_kstat = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_SUSFS_SUS_SU
|
||||||
|
status.status_sus_su = true;
|
||||||
|
#else
|
||||||
|
status.status_sus_su = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (copy_to_user((void __user*)arg3, &status, sizeof(status))) {
|
||||||
|
pr_err("susfs_feature_status: copy_to_user failed\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (copy_to_user(result, &reply_ok, sizeof(reply_ok))) {
|
||||||
|
pr_err("susfs_feature_status: prctl reply error\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
pr_info("susfs_feature_status: successfully returned feature status\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_KSU_SUSFS
|
#ifdef CONFIG_KSU_SUSFS
|
||||||
if (current_uid_val == 0) {
|
if (current_uid_val == 0) {
|
||||||
#ifdef CONFIG_KSU_SUSFS_SUS_PATH
|
#ifdef CONFIG_KSU_SUSFS_SUS_PATH
|
||||||
|
|||||||
20
kernel/ksu.h
20
kernel/ksu.h
@@ -25,6 +25,7 @@
|
|||||||
#define CMD_ENABLE_SU 15
|
#define CMD_ENABLE_SU 15
|
||||||
#define CMD_ENABLE_KPM 100
|
#define CMD_ENABLE_KPM 100
|
||||||
#define CMD_HOOK_TYPE 101
|
#define CMD_HOOK_TYPE 101
|
||||||
|
#define CMD_GET_SUSFS_FEATURE_STATUS 102
|
||||||
|
|
||||||
#define EVENT_POST_FS_DATA 1
|
#define EVENT_POST_FS_DATA 1
|
||||||
#define EVENT_BOOT_COMPLETED 2
|
#define EVENT_BOOT_COMPLETED 2
|
||||||
@@ -36,6 +37,25 @@
|
|||||||
#define KSU_MAX_GROUPS 32
|
#define KSU_MAX_GROUPS 32
|
||||||
#define KSU_SELINUX_DOMAIN 64
|
#define KSU_SELINUX_DOMAIN 64
|
||||||
|
|
||||||
|
// SUSFS Functional State Structures
|
||||||
|
struct susfs_feature_status {
|
||||||
|
bool status_sus_path;
|
||||||
|
bool status_sus_mount;
|
||||||
|
bool status_auto_default_mount;
|
||||||
|
bool status_auto_bind_mount;
|
||||||
|
bool status_sus_kstat;
|
||||||
|
bool status_try_umount;
|
||||||
|
bool status_auto_try_umount_bind;
|
||||||
|
bool status_spoof_uname;
|
||||||
|
bool status_enable_log;
|
||||||
|
bool status_hide_symbols;
|
||||||
|
bool status_spoof_cmdline;
|
||||||
|
bool status_open_redirect;
|
||||||
|
bool status_magic_mount;
|
||||||
|
bool status_overlayfs_auto_kstat;
|
||||||
|
bool status_sus_su;
|
||||||
|
};
|
||||||
|
|
||||||
struct root_profile {
|
struct root_profile {
|
||||||
int32_t uid;
|
int32_t uid;
|
||||||
int32_t gid;
|
int32_t gid;
|
||||||
|
|||||||
Reference in New Issue
Block a user