kernel, ksud, manager: New supercalls implementations
* This commit squashes new supercall impl:
3138651a38..562a3b9be7
Thanks to these people below:
Official KernelSU:
Co-authored-by: Wang Han <416810799@qq.com>
Co-authored-by: weishu <twsxtd@gmail.com>
Co-authored-by: Ylarod <me@ylarod.cn>
Co-authored-by: YuKongA <70465933+YuKongA@users.noreply.github.com>
xxKSU maintainer:
Co-authored-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
MMRL maintainer:
Co-authored-by: Der_Googler <54764558+dergoogler@users.noreply.github.com>
KSUN maintainer:
Co-authored-by: Rifat Azad <33044977+rifsxd@users.noreply.github.com>
KOWSU maintainer:
Co-authored-by: KOWX712 <leecc0503@gmail.com>
This commit is contained in:
@@ -157,39 +157,16 @@ void apply_kernelsu_rules(void)
|
||||
#define CMD_TYPE_CHANGE 8
|
||||
#define CMD_GENFSCON 9
|
||||
|
||||
// keep it!
|
||||
extern bool ksu_is_compat __read_mostly;
|
||||
|
||||
// armv7l kernel compat
|
||||
#ifdef CONFIG_64BIT
|
||||
#define usize u64
|
||||
#else
|
||||
#define usize u32
|
||||
#endif
|
||||
|
||||
struct sepol_data {
|
||||
u32 cmd;
|
||||
u32 subcmd;
|
||||
usize field_sepol1;
|
||||
usize field_sepol2;
|
||||
usize field_sepol3;
|
||||
usize field_sepol4;
|
||||
usize field_sepol5;
|
||||
usize field_sepol6;
|
||||
usize field_sepol7;
|
||||
};
|
||||
|
||||
// ksud 32-bit on arm64 kernel
|
||||
struct __maybe_unused sepol_data_compat {
|
||||
u32 cmd;
|
||||
u32 subcmd;
|
||||
u32 field_sepol1;
|
||||
u32 field_sepol2;
|
||||
u32 field_sepol3;
|
||||
u32 field_sepol4;
|
||||
u32 field_sepol5;
|
||||
u32 field_sepol6;
|
||||
u32 field_sepol7;
|
||||
uint32_t cmd;
|
||||
uint32_t subcmd;
|
||||
uint64_t field_sepol1;
|
||||
uint64_t field_sepol2;
|
||||
uint64_t field_sepol3;
|
||||
uint64_t field_sepol4;
|
||||
uint64_t field_sepol5;
|
||||
uint64_t field_sepol6;
|
||||
uint64_t field_sepol7;
|
||||
};
|
||||
|
||||
static int get_object(char *buf, char __user *user_object, size_t buf_sz,
|
||||
@@ -212,7 +189,7 @@ static int get_object(char *buf, char __user *user_object, size_t buf_sz,
|
||||
// reset avc cache table, otherwise the new rules will not take effect if already denied
|
||||
static void reset_avc_cache(void)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0) || \
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0) || \
|
||||
!defined(KSU_COMPAT_USE_SELINUX_STATE)
|
||||
avc_ss_reset(0);
|
||||
selnl_notify_policyload(0);
|
||||
@@ -242,40 +219,22 @@ int handle_sepolicy(unsigned long arg3, void __user *arg4)
|
||||
char __user *sepol1, *sepol2, *sepol3, *sepol4, *sepol5, *sepol6,
|
||||
*sepol7;
|
||||
|
||||
if (unlikely(ksu_is_compat)) {
|
||||
struct sepol_data_compat data_compat;
|
||||
if (copy_from_user(&data_compat, arg4,
|
||||
sizeof(struct sepol_data_compat))) {
|
||||
pr_err("sepol: copy sepol_data failed.\n");
|
||||
return -1;
|
||||
}
|
||||
pr_info("sepol: running in compat mode!\n");
|
||||
sepol1 = compat_ptr(data_compat.field_sepol1);
|
||||
sepol2 = compat_ptr(data_compat.field_sepol2);
|
||||
sepol3 = compat_ptr(data_compat.field_sepol3);
|
||||
sepol4 = compat_ptr(data_compat.field_sepol4);
|
||||
sepol5 = compat_ptr(data_compat.field_sepol5);
|
||||
sepol6 = compat_ptr(data_compat.field_sepol6);
|
||||
sepol7 = compat_ptr(data_compat.field_sepol7);
|
||||
cmd = data_compat.cmd;
|
||||
subcmd = data_compat.subcmd;
|
||||
} else {
|
||||
struct sepol_data data;
|
||||
if (copy_from_user(&data, arg4, sizeof(struct sepol_data))) {
|
||||
pr_err("sepol: copy sepol_data failed.\n");
|
||||
return -1;
|
||||
}
|
||||
sepol1 = data.field_sepol1;
|
||||
sepol2 = data.field_sepol2;
|
||||
sepol3 = data.field_sepol3;
|
||||
sepol4 = data.field_sepol4;
|
||||
sepol5 = data.field_sepol5;
|
||||
sepol6 = data.field_sepol6;
|
||||
sepol7 = data.field_sepol7;
|
||||
cmd = data.cmd;
|
||||
subcmd = data.subcmd;
|
||||
struct sepol_data data = { 0 };
|
||||
if (copy_from_user(&data, arg4, sizeof(struct sepol_data))) {
|
||||
pr_err("sepol: copy sepol_data failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
sepol1 = (char __user *)data.field_sepol1;
|
||||
sepol2 = (char __user *)data.field_sepol2;
|
||||
sepol3 = (char __user *)data.field_sepol3;
|
||||
sepol4 = (char __user *)data.field_sepol4;
|
||||
sepol5 = (char __user *)data.field_sepol5;
|
||||
sepol6 = (char __user *)data.field_sepol6;
|
||||
sepol7 = (char __user *)data.field_sepol7;
|
||||
cmd = data.cmd;
|
||||
subcmd = data.subcmd;
|
||||
|
||||
mutex_lock(&ksu_rules);
|
||||
|
||||
db = get_policydb();
|
||||
|
||||
Reference in New Issue
Block a user