Skip to content

Commit

Permalink
drivers: kernelsu: update to v0.9.4
Browse files Browse the repository at this point in the history
also set gitversion to 1638

Signed-off-by: engstk <[email protected]>
  • Loading branch information
engstk committed May 9, 2024
1 parent 9892d6a commit cadc338
Show file tree
Hide file tree
Showing 24 changed files with 435 additions and 235 deletions.
2 changes: 1 addition & 1 deletion drivers/kernelsu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ obj-$(CONFIG_KSU) += kernelsu.o
# ifeq ($(shell test -e $(srctree)/$(src)/../.git; echo $$?),0)
# $(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin [ -f ../.git/shallow ] && git fetch --unshallow)
# KSU_GIT_VERSION := $(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin git rev-list --count HEAD)
KSU_GIT_VERSION := 1604
KSU_GIT_VERSION := 1638
# ksu_version: major * 10000 + git version + 200 for historical reasons
$(eval KSU_VERSION=$(shell expr 10000 + $(KSU_GIT_VERSION) + 200))
$(info -- KernelSU version: $(KSU_VERSION))
Expand Down
22 changes: 11 additions & 11 deletions drivers/kernelsu/allowlist.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include "ksu.h"
#include "linux/compiler.h"
#include "linux/fs.h"
#include "linux/gfp.h"
#include "linux/kernel.h"
#include "linux/list.h"
#include "linux/printk.h"
#include "linux/slab.h"
#include "linux/types.h"
#include "linux/version.h"
#include <linux/compiler.h>
#include <linux/fs.h>
#include <linux/gfp.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/printk.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
#include "linux/compiler_types.h"
#include <linux/compiler_types.h>
#endif

#include "ksu.h"
#include "klog.h" // IWYU pragma: keep
#include "selinux/selinux.h"
#include "kernel_compat.h"
Expand Down
2 changes: 1 addition & 1 deletion drivers/kernelsu/allowlist.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __KSU_H_ALLOWLIST
#define __KSU_H_ALLOWLIST

#include "linux/types.h"
#include <linux/types.h>
#include "ksu.h"

void ksu_allowlist_init(void);
Expand Down
34 changes: 18 additions & 16 deletions drivers/kernelsu/apk_sign.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#include "linux/err.h"
#include "linux/fs.h"
#include "linux/gfp.h"
#include "linux/kernel.h"
#include "linux/moduleparam.h"
#include <linux/err.h>
#include <linux/fs.h>
#include <linux/gfp.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/version.h>
#ifdef CONFIG_KSU_DEBUG
#include <linux/moduleparam.h>
#endif
#include <crypto/hash.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
#include <crypto/sha2.h>
#else
#include <crypto/sha.h>
#endif

#include "apk_sign.h"
#include "klog.h" // IWYU pragma: keep
#include "kernel_compat.h"
#include "crypto/hash.h"
#include "linux/slab.h"
#include "linux/version.h"

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
#include "crypto/sha2.h"
#else
#include "crypto/sha.h"
#endif

struct sdesc {
struct shash_desc shash;
Expand Down Expand Up @@ -229,7 +231,7 @@ static __always_inline bool check_v2_signature(char *path,
goto clean;
}

int loop_count = 0;
int loop_count = 0;
while (loop_count++ < 10) {
uint32_t id;
uint32_t offset;
Expand Down Expand Up @@ -307,8 +309,8 @@ static struct kernel_param_ops expected_size_ops = {
.get = param_get_uint,
};

module_param_cb(ksu_debug_manager_uid, &expected_size_ops, &ksu_debug_manager_uid,
S_IRUSR | S_IWUSR);
module_param_cb(ksu_debug_manager_uid, &expected_size_ops,
&ksu_debug_manager_uid, S_IRUSR | S_IWUSR);

#endif

Expand Down
2 changes: 1 addition & 1 deletion drivers/kernelsu/apk_sign.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __KSU_H_APK_V2_SIGN
#define __KSU_H_APK_V2_SIGN

#include "linux/types.h"
#include <linux/types.h>

bool is_manager_apk(char *path);

Expand Down
12 changes: 11 additions & 1 deletion drivers/kernelsu/arch.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __KSU_H_ARCH
#define __KSU_H_ARCH

#include "linux/version.h"
#include <linux/version.h>

#if defined(__aarch64__)

Expand All @@ -23,11 +23,13 @@
#define SYS_READ_SYMBOL "__arm64_sys_read"
#define SYS_NEWFSTATAT_SYMBOL "__arm64_sys_newfstatat"
#define SYS_FACCESSAT_SYMBOL "__arm64_sys_faccessat"
#define SYS_EXECVE_SYMBOL "__arm64_sys_execve"
#else
#define PRCTL_SYMBOL "sys_prctl"
#define SYS_READ_SYMBOL "sys_read"
#define SYS_NEWFSTATAT_SYMBOL "sys_newfstatat"
#define SYS_FACCESSAT_SYMBOL "sys_faccessat"
#define SYS_EXECVE_SYMBOL "sys_execve"
#endif

#elif defined(__x86_64__)
Expand All @@ -50,11 +52,13 @@
#define SYS_READ_SYMBOL "__x64_sys_read"
#define SYS_NEWFSTATAT_SYMBOL "__x64_sys_newfstatat"
#define SYS_FACCESSAT_SYMBOL "__x64_sys_faccessat"
#define SYS_EXECVE_SYMBOL "__x64_sys_execve"
#else
#define PRCTL_SYMBOL "sys_prctl"
#define SYS_READ_SYMBOL "sys_read"
#define SYS_NEWFSTATAT_SYMBOL "sys_newfstatat"
#define SYS_FACCESSAT_SYMBOL "sys_faccessat"
#define SYS_EXECVE_SYMBOL "sys_execve"
#endif

#else
Expand All @@ -79,4 +83,10 @@
#define PT_REGS_SP(x) (__PT_REGS_CAST(x)->__PT_SP_REG)
#define PT_REGS_IP(x) (__PT_REGS_CAST(x)->__PT_IP_REG)

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)
#define PT_REAL_REGS(regs) ((struct pt_regs *)PT_REGS_PARM1(regs))
#else
#define PT_REAL_REGS(regs) ((regs))
#endif

#endif
69 changes: 34 additions & 35 deletions drivers/kernelsu/core_hook.c
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
#include "linux/capability.h"
#include "linux/cred.h"
#include "linux/dcache.h"
#include "linux/err.h"
#include "linux/init.h"
#include "linux/init_task.h"
#include "linux/irqflags.h"
#include "linux/kallsyms.h"
#include "linux/kernel.h"
#include "linux/kprobes.h"
#include "linux/list.h"
#include "linux/lsm_hooks.h"
#include "linux/mm.h"
#include "linux/mm_types.h"
#include "linux/nsproxy.h"
#include "linux/path.h"
#include "linux/printk.h"
#include "linux/sched.h"
#include "linux/security.h"
#include "linux/stddef.h"
#include "linux/types.h"
#include "linux/uaccess.h"
#include "linux/uidgid.h"
#include "linux/version.h"
#include "linux/mount.h"

#include "linux/fs.h"
#include "linux/namei.h"
#include "linux/rcupdate.h"
#include <linux/capability.h>
#include <linux/cred.h>
#include <linux/dcache.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/init_task.h>
#include <linux/kallsyms.h>
#include <linux/kernel.h>
#include <linux/kprobes.h>
#include <linux/lsm_hooks.h>
#include <linux/mm.h>
#include <linux/nsproxy.h>
#include <linux/path.h>
#include <linux/printk.h>
#include <linux/sched.h>
#include <linux/security.h>
#include <linux/stddef.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/uidgid.h>
#include <linux/version.h>
#include <linux/mount.h>

#include <linux/fs.h>
#include <linux/namei.h>

#ifdef MODULE
#include <linux/list.h>
#include <linux/irqflags.h>
#include <linux/mm_types.h>
#include <linux/rcupdate.h>
#include <linux/vmalloc.h>
#endif

#include "allowlist.h"
#include "arch.h"
#include "core_hook.h"
#include "klog.h" // IWYU pragma: keep
#include "ksu.h"
#include "ksud.h"
#include "linux/vmalloc.h"
#include "manager.h"
#include "selinux/selinux.h"
#include "throne_tracker.h"
Expand Down Expand Up @@ -542,11 +545,7 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)

static int handler_pre(struct kprobe *p, struct pt_regs *regs)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)
struct pt_regs *real_regs = (struct pt_regs *)PT_REGS_PARM1(regs);
#else
struct pt_regs *real_regs = regs;
#endif
struct pt_regs *real_regs = PT_REAL_REGS(regs);
int option = (int)PT_REGS_PARM1(real_regs);
unsigned long arg2 = (unsigned long)PT_REGS_PARM2(real_regs);
unsigned long arg3 = (unsigned long)PT_REGS_PARM3(real_regs);
Expand Down
2 changes: 1 addition & 1 deletion drivers/kernelsu/core_hook.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __KSU_H_KSU_CORE
#define __KSU_H_KSU_CORE

#include "linux/init.h"
#include <linux/init.h>

void __init ksu_core_init(void);
void ksu_core_exit(void);
Expand Down
4 changes: 2 additions & 2 deletions drivers/kernelsu/include/ksu_hook.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef __KSU_H_KSHOOK
#define __KSU_H_KSHOOK

#include "linux/fs.h"
#include "linux/types.h"
#include <linux/fs.h>
#include <linux/types.h>

// For sucompat

Expand Down
18 changes: 9 additions & 9 deletions drivers/kernelsu/kernel_compat.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#include "linux/version.h"
#include "linux/fs.h"
#include "linux/nsproxy.h"
#include <linux/version.h>
#include <linux/fs.h>
#include <linux/nsproxy.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#include "linux/sched/task.h"
#include <linux/sched/task.h>
#else
#include "linux/sched.h"
#include <linux/sched.h>
#endif
#include "linux/uaccess.h"
#include <linux/uaccess.h>
#include "klog.h" // IWYU pragma: keep
#include "kernel_compat.h" // Add check Huawei Device

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) || defined(CONFIG_IS_HW_HISI)
#include "linux/key.h"
#include "linux/errno.h"
#include "linux/cred.h"
#include <linux/key.h>
#include <linux/errno.h>
#include <linux/cred.h>
struct key *init_session_keyring = NULL;

static inline int install_session_keyring(struct key *keyring)
Expand Down
6 changes: 3 additions & 3 deletions drivers/kernelsu/kernel_compat.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef __KSU_H_KERNEL_COMPAT
#define __KSU_H_KERNEL_COMPAT

#include "linux/fs.h"
#include "linux/key.h"
#include "linux/version.h"
#include <linux/fs.h>
#include <linux/version.h>
#include "ss/policydb.h"
#include "linux/key.h"

/*
* Adapt to Huawei HISI kernel without affecting other kernels ,
Expand Down
10 changes: 5 additions & 5 deletions drivers/kernelsu/ksu.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "linux/export.h"
#include "linux/fs.h"
#include "linux/kobject.h"
#include "linux/module.h"
#include "linux/workqueue.h"
#include <linux/export.h>
#include <linux/fs.h>
#include <linux/kobject.h>
#include <linux/module.h>
#include <linux/workqueue.h>

#include "allowlist.h"
#include "arch.h"
Expand Down
4 changes: 2 additions & 2 deletions drivers/kernelsu/ksu.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef __KSU_H_KSU
#define __KSU_H_KSU

#include "linux/types.h"
#include "linux/workqueue.h"
#include <linux/types.h>
#include <linux/workqueue.h>

#define KERNEL_SU_VERSION KSU_VERSION
#define KERNEL_SU_OPTION 0xDEADBEEF
Expand Down
Loading

0 comments on commit cadc338

Please sign in to comment.