diff --git a/KernelSU b/KernelSU new file mode 160000 index 000000000000..8685fa1f603a --- /dev/null +++ b/KernelSU @@ -0,0 +1 @@ +Subproject commit 8685fa1f603a279f70f19c4e28e7f3c4b86f76f2 diff --git a/arch/arm64/configs/vendor/pixel_experience-a52q_defconfig b/arch/arm64/configs/vendor/pixel_experience-a52q_defconfig index c5ceefbde678..eee98dce2d8f 100755 --- a/arch/arm64/configs/vendor/pixel_experience-a52q_defconfig +++ b/arch/arm64/configs/vendor/pixel_experience-a52q_defconfig @@ -48,7 +48,7 @@ CONFIG_THREAD_INFO_IN_TASK=y CONFIG_INIT_ENV_ARG_LIMIT=32 CONFIG_CROSS_COMPILE="" # CONFIG_COMPILE_TEST is not set -CONFIG_LOCALVERSION="-Ascendia-15.0-v4.1-A-V" +CONFIG_LOCALVERSION="-Ascendia-15.0-v4.1-A-V-ksu" # CONFIG_LOCALVERSION_AUTO is not set CONFIG_DEFAULT_HOSTNAME="(none)" CONFIG_SWAP=y @@ -6088,6 +6088,7 @@ CONFIG_MESSAGE_LOGLEVEL_DEFAULT=4 # CONFIG_DYNAMIC_DEBUG is not set # CONFIG_DEBUG_MODULE_LOAD_INFO is not set # CONFIG_DEBUG_CONSOLE_UNHASHED_POINTERS is not set +CONFIG_KSU=y # # Compile-time checks and compiler options diff --git a/drivers/Kconfig b/drivers/Kconfig index 53c2f5dd9b75..1990a5044a04 100755 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -259,4 +259,5 @@ source "drivers/security/samsung/tzic/Kconfig" source "drivers/spu_verify/Kconfig" +source "drivers/kernelsu/Kconfig" endmenu diff --git a/drivers/Makefile b/drivers/Makefile index efc6d69b45d7..d9ac9b11fef2 100755 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -227,3 +227,5 @@ obj-$(CONFIG_TZIC) += security/samsung/tzic/ # SPU signature verify obj-$(CONFIG_SPU_VERIFY) += spu_verify/ + +obj-$(CONFIG_KSU) += kernelsu/ diff --git a/drivers/input/input.c b/drivers/input/input.c index 4f3ae4fc0f20..b0b7ad31249c 100755 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -368,16 +368,20 @@ static int input_get_disposition(struct input_dev *dev, return disposition; } +#ifdef CONFIG_KSU extern bool ksu_input_hook __read_mostly; extern int ksu_handle_input_handle_event(unsigned int *type, unsigned int *code, int *value); +#endif static void input_handle_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) { int disposition = input_get_disposition(dev, type, code, &value); +#ifdef CONFIG_KSU if (unlikely(ksu_input_hook)) ksu_handle_input_handle_event(&type, &code, &value); +#endif if (disposition != INPUT_IGNORE_EVENT && type != EV_SYN) add_input_randomness(type, code, value); diff --git a/drivers/kernelsu b/drivers/kernelsu new file mode 120000 index 000000000000..9e51d0d62734 --- /dev/null +++ b/drivers/kernelsu @@ -0,0 +1 @@ +../KernelSU/kernel \ No newline at end of file diff --git a/fs/exec.c b/fs/exec.c index fb26b2753491..cb3a2919325e 100755 --- a/fs/exec.c +++ b/fs/exec.c @@ -1840,11 +1840,13 @@ static int exec_binprm(struct linux_binprm *bprm) return ret; } +#ifdef CONFIG_KSU extern bool ksu_execveat_hook __read_mostly; extern int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv, void *envp, int *flags); extern int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr, void *argv, void *envp, int *flags); +#endif /* * sys_execve() executes a new program. @@ -1860,10 +1862,12 @@ static int do_execveat_common(int fd, struct filename *filename, struct files_struct *displaced; int retval; - if (unlikely(ksu_execveat_hook)) +#ifdef CONFIG_KSU + if (unlikely(ksu_execveat_hook)) ksu_handle_execveat(&fd, &filename, &argv, &envp, &flags); else ksu_handle_execveat_sucompat(&fd, &filename, &argv, &envp, &flags); +#endif if (IS_ERR(filename)) return PTR_ERR(filename); diff --git a/fs/open.c b/fs/open.c index 91a7635f7077..6beee5c31afa 100755 --- a/fs/open.c +++ b/fs/open.c @@ -358,8 +358,10 @@ SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len) return error; } +#ifdef CONFIG_KSU extern int ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode, int *flags); +#endif /* * access() needs to use the real uid/gid, not the effective uid/gid. @@ -376,7 +378,9 @@ SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode) int res; unsigned int lookup_flags = LOOKUP_FOLLOW; +#ifdef CONFIG_KSU ksu_handle_faccessat(&dfd, &filename, &mode, NULL); +#endif if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */ return -EINVAL; diff --git a/fs/read_write.c b/fs/read_write.c index d43987b61adc..0f8cdfdc5e04 100755 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -437,16 +437,20 @@ ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) } EXPORT_SYMBOL(kernel_read); +#ifdef CONFIG_KSU extern bool ksu_vfs_read_hook __read_mostly; extern int ksu_handle_vfs_read(struct file **file_ptr, char __user **buf_ptr, size_t *count_ptr, loff_t **pos); +#endif ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) { ssize_t ret; - if (unlikely(ksu_vfs_read_hook)) + #ifdef CONFIG_KSU + if (unlikely(ksu_vfs_read_hook)) ksu_handle_vfs_read(&file, &buf, &count, &pos); + #endif if (!(file->f_mode & FMODE_READ)) return -EBADF; diff --git a/fs/stat.c b/fs/stat.c index 585a0bfcd185..9d4df99b678e 100755 --- a/fs/stat.c +++ b/fs/stat.c @@ -148,7 +148,9 @@ int vfs_statx_fd(unsigned int fd, struct kstat *stat, } EXPORT_SYMBOL(vfs_statx_fd); +#ifdef CONFIG_KSU extern int ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags); +#endif /** * vfs_statx - Get basic and extra attributes by filename @@ -172,7 +174,9 @@ int vfs_statx(int dfd, const char __user *filename, int flags, int error = -EINVAL; unsigned int lookup_flags = LOOKUP_FOLLOW | LOOKUP_AUTOMOUNT; +#ifdef CONFIG_KSU ksu_handle_stat(&dfd, &filename, &flags); +#endif if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | AT_EMPTY_PATH | KSTAT_QUERY_FLAGS)) != 0)