mirror of
https://github.com/tiann/KernelSU.git
synced 2025-02-20 11:43:32 +08:00
kernel: fix compile errors & warnings on android13-5.15 gki
This commit is contained in:
parent
c5da14ae4b
commit
758c8eb845
@ -87,13 +87,14 @@ exit:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ksu_is_allow_uid(uid_t uid) {
|
bool ksu_is_allow_uid(uid_t uid) {
|
||||||
|
struct perm_data *p = NULL;
|
||||||
|
struct list_head *pos = NULL;
|
||||||
|
|
||||||
if (uid == 0) {
|
if (uid == 0) {
|
||||||
// already root
|
// already root
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct perm_data *p = NULL;
|
|
||||||
struct list_head *pos = NULL;
|
|
||||||
list_for_each(pos, &allow_list) {
|
list_for_each(pos, &allow_list) {
|
||||||
p = list_entry(pos, struct perm_data, list);
|
p = list_entry(pos, struct perm_data, list);
|
||||||
// pr_info("is_allow_uid uid :%d, allow: %d\n", p->uid, p->allow);
|
// pr_info("is_allow_uid uid :%d, allow: %d\n", p->uid, p->allow);
|
||||||
@ -162,7 +163,6 @@ void do_load_allow_list(struct work_struct *work) {
|
|||||||
loff_t off = 0;
|
loff_t off = 0;
|
||||||
ssize_t ret = 0;
|
ssize_t ret = 0;
|
||||||
struct file *fp = NULL;
|
struct file *fp = NULL;
|
||||||
int n = 0;
|
|
||||||
u32 magic;
|
u32 magic;
|
||||||
u32 version;
|
u32 version;
|
||||||
|
|
||||||
|
46
kernel/ksu.c
46
kernel/ksu.c
@ -83,21 +83,25 @@ static bool is_manager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool become_manager() {
|
static bool become_manager() {
|
||||||
if (__manager_uid != 0) {
|
|
||||||
pr_info("manager already exist: %d\n", __manager_uid);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// list current process's files
|
|
||||||
struct files_struct *current_files;
|
|
||||||
struct fdtable *files_table;
|
struct fdtable *files_table;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
struct path files_path;
|
struct path files_path;
|
||||||
char *cwd;
|
char *cwd;
|
||||||
char *buf = (char *)kmalloc(GFP_KERNEL, PATH_MAX);
|
char *buf;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
current_files = current->files;
|
if (__manager_uid != 0) {
|
||||||
files_table = files_fdtable(current_files);
|
pr_info("manager already exist: %d\n", __manager_uid);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf = (char *) kmalloc(GFP_KERNEL, PATH_MAX);
|
||||||
|
if (!buf) {
|
||||||
|
pr_err("kalloc path failed.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
files_table = files_fdtable(current->files);
|
||||||
|
|
||||||
// todo: use iterate_fd
|
// todo: use iterate_fd
|
||||||
while(files_table->fd[i] != NULL) {
|
while(files_table->fd[i] != NULL) {
|
||||||
@ -168,7 +172,9 @@ static int handler_pre(struct kprobe *p, struct pt_regs *regs) {
|
|||||||
// someone wants to be root manager, just check it!
|
// someone wants to be root manager, just check it!
|
||||||
bool success = become_manager();
|
bool success = become_manager();
|
||||||
if (success) {
|
if (success) {
|
||||||
copy_to_user(result, &reply_ok, sizeof(reply_ok));
|
if (copy_to_user(result, &reply_ok, sizeof(reply_ok))) {
|
||||||
|
pr_err("prctl reply error\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -198,21 +204,29 @@ static int handler_pre(struct kprobe *p, struct pt_regs *regs) {
|
|||||||
uid_t uid = (uid_t) arg3;
|
uid_t uid = (uid_t) arg3;
|
||||||
success = ksu_allow_uid(uid, allow);
|
success = ksu_allow_uid(uid, allow);
|
||||||
if (success) {
|
if (success) {
|
||||||
copy_to_user(result, &reply_ok, sizeof(reply_ok));
|
if (copy_to_user(result, &reply_ok, sizeof(reply_ok))) {
|
||||||
|
pr_err("prctl reply error, cmd: %d\n", arg2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (arg2 == CMD_GET_ALLOW_LIST || arg2 == CMD_GET_DENY_LIST) {
|
} else if (arg2 == CMD_GET_ALLOW_LIST || arg2 == CMD_GET_DENY_LIST) {
|
||||||
u32 array[128];
|
u32 array[128];
|
||||||
u32 array_length;
|
u32 array_length;
|
||||||
bool success = ksu_get_allow_list(array, &array_length, arg2 == CMD_GET_ALLOW_LIST);
|
bool success = ksu_get_allow_list(array, &array_length, arg2 == CMD_GET_ALLOW_LIST);
|
||||||
if (success) {
|
if (success) {
|
||||||
copy_to_user(arg4, &array_length, sizeof(array_length));
|
if (!copy_to_user(arg4, &array_length, sizeof(array_length)) &&
|
||||||
copy_to_user(arg3, array, sizeof(u32) * array_length);
|
!copy_to_user(arg3, array, sizeof(u32) * array_length)) {
|
||||||
|
if (!copy_to_user(result, &reply_ok, sizeof(reply_ok))) {
|
||||||
copy_to_user(result, &reply_ok, sizeof(reply_ok));
|
pr_err("prctl reply error, cmd: %d\n", arg2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pr_err("prctl copy allowlist error\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (arg2 == CMD_GET_VERSION) {
|
} else if (arg2 == CMD_GET_VERSION) {
|
||||||
u32 version = KERNEL_SU_VERSION;
|
u32 version = KERNEL_SU_VERSION;
|
||||||
copy_to_user(arg3, &version, sizeof(version));
|
if (copy_to_user(arg3, &version, sizeof(version))) {
|
||||||
|
pr_err("prctl reply error, cmd: %d\n", arg2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -93,13 +93,14 @@ static int execve_handler_pre(struct kprobe *p, struct pt_regs *regs) {
|
|||||||
const char sh[] = SH_PATH;
|
const char sh[] = SH_PATH;
|
||||||
const char su[] = SU_PATH;
|
const char su[] = SU_PATH;
|
||||||
|
|
||||||
|
static const char app_process[] = "/system/bin/app_process";
|
||||||
|
static bool first_app_process = true;
|
||||||
|
|
||||||
filename = PT_REGS_PARM2(regs);
|
filename = PT_REGS_PARM2(regs);
|
||||||
if (IS_ERR(filename)) {
|
if (IS_ERR(filename)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char app_process[] = "/system/bin/app_process";
|
|
||||||
static bool first_app_process = true;
|
|
||||||
if (first_app_process && !memcmp(filename->name, app_process, sizeof(app_process) - 1)) {
|
if (first_app_process && !memcmp(filename->name, app_process, sizeof(app_process) - 1)) {
|
||||||
first_app_process = false;
|
first_app_process = false;
|
||||||
pr_info("exec app_process, /data prepared!\n");
|
pr_info("exec app_process, /data prepared!\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user