|
| 1 | +diff --git a/drivers/input/input.c b/drivers/input/input.c |
| 2 | +index 78be582b5766..c2045ade6ccc 100644 |
| 3 | +--- a/drivers/input/input.c |
| 4 | ++++ b/drivers/input/input.c |
| 5 | +@@ -420,11 +420,21 @@ void input_handle_event(struct input_dev *dev, |
| 6 | + * to 'seed' initial state of a switch or initial position of absolute |
| 7 | + * axis, etc. |
| 8 | + */ |
| 9 | ++#if defined(CONFIG_KSU) && !defined(CONFIG_KSU_KPROBES_HOOK) |
| 10 | ++extern bool ksu_input_hook __read_mostly; |
| 11 | ++extern int ksu_handle_input_handle_event(unsigned int *type, unsigned int *code, int *value); |
| 12 | ++#endif |
| 13 | ++ |
| 14 | + void input_event(struct input_dev *dev, |
| 15 | + unsigned int type, unsigned int code, int value) |
| 16 | + { |
| 17 | + unsigned long flags; |
| 18 | + |
| 19 | ++#if defined(CONFIG_KSU) && !defined(CONFIG_KSU_KPROBES_HOOK) |
| 20 | ++ if (unlikely(ksu_input_hook)) |
| 21 | ++ ksu_handle_input_handle_event(&type, &code, &value); |
| 22 | ++#endif |
| 23 | ++ |
| 24 | + if (is_event_supported(type, dev->evbit, EV_MAX)) { |
| 25 | + |
| 26 | + spin_lock_irqsave(&dev->event_lock, flags); |
| 27 | +diff --git a/fs/exec.c b/fs/exec.c |
| 28 | +index 78e15a17c3e5..78d076116855 100644 |
| 29 | +--- a/fs/exec.c |
| 30 | ++++ b/fs/exec.c |
| 31 | +@@ -2122,11 +2122,21 @@ void set_dumpable(struct mm_struct *mm, int value) |
| 32 | + set_mask_bits(&mm->flags, MMF_DUMPABLE_MASK, value); |
| 33 | + } |
| 34 | + |
| 35 | ++#if defined(CONFIG_KSU) && !defined(CONFIG_KSU_KPROBES_HOOK) |
| 36 | ++__attribute__((hot)) |
| 37 | ++extern int ksu_handle_execve_sucompat(int *fd, const char __user **filename_user, |
| 38 | ++ void *__never_use_argv, void *__never_use_envp, |
| 39 | ++ int *__never_use_flags); |
| 40 | ++#endif |
| 41 | ++ |
| 42 | + SYSCALL_DEFINE3(execve, |
| 43 | + const char __user *, filename, |
| 44 | + const char __user *const __user *, argv, |
| 45 | + const char __user *const __user *, envp) |
| 46 | + { |
| 47 | ++#if defined(CONFIG_KSU) && !defined(CONFIG_KSU_KPROBES_HOOK) |
| 48 | ++ ksu_handle_execve_sucompat((int *)AT_FDCWD, &filename, NULL, NULL, NULL); |
| 49 | ++#endif |
| 50 | + return do_execve(getname(filename), argv, envp); |
| 51 | + } |
| 52 | + |
| 53 | +@@ -2146,6 +2156,9 @@ COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename, |
| 54 | + const compat_uptr_t __user *, argv, |
| 55 | + const compat_uptr_t __user *, envp) |
| 56 | + { |
| 57 | ++#if defined(CONFIG_KSU) && !defined(CONFIG_KSU_KPROBES_HOOK) // 32-bit su and 32-on-64 support |
| 58 | ++ ksu_handle_execve_sucompat((int *)AT_FDCWD, &filename, NULL, NULL, NULL); |
| 59 | ++#endif |
| 60 | + return compat_do_execve(getname(filename), argv, envp); |
| 61 | + } |
| 62 | + |
| 63 | +diff --git a/fs/open.c b/fs/open.c |
| 64 | +index f5a50cc9cd12..fd694b702278 100644 |
| 65 | +--- a/fs/open.c |
| 66 | ++++ b/fs/open.c |
| 67 | +@@ -512,8 +512,17 @@ static long do_faccessat(int dfd, const char __user *filename, int mode, int fla |
| 68 | + return res; |
| 69 | + } |
| 70 | + |
| 71 | ++#if defined(CONFIG_KSU) && !defined(CONFIG_KSU_KPROBES_HOOK) |
| 72 | ++__attribute__((hot)) |
| 73 | ++extern int ksu_handle_faccessat(int *dfd, const char __user **filename_user, |
| 74 | ++ int *mode, int *flags); |
| 75 | ++#endif |
| 76 | ++ |
| 77 | + SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode) |
| 78 | + { |
| 79 | ++#if defined(CONFIG_KSU) && !defined(CONFIG_KSU_KPROBES_HOOK) |
| 80 | ++ ksu_handle_faccessat(&dfd, &filename, &mode, NULL); |
| 81 | ++#endif |
| 82 | + return do_faccessat(dfd, filename, mode, 0); |
| 83 | + } |
| 84 | + |
| 85 | +diff --git a/fs/read_write.c b/fs/read_write.c |
| 86 | +index 7a2ff6157eda..c7a5e8ec2988 100644 |
| 87 | +--- a/fs/read_write.c |
| 88 | ++++ b/fs/read_write.c |
| 89 | +@@ -618,8 +618,18 @@ ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count) |
| 90 | + return ret; |
| 91 | + } |
| 92 | + |
| 93 | ++#if defined(CONFIG_KSU) && !defined(CONFIG_KSU_KPROBES_HOOK) |
| 94 | ++extern bool ksu_vfs_read_hook __read_mostly; |
| 95 | ++extern int ksu_handle_sys_read(unsigned int fd, char __user **buf_ptr, |
| 96 | ++ size_t *count_ptr); |
| 97 | ++#endif |
| 98 | ++ |
| 99 | + SYSCALL_DEFINE3(read, unsigned int, fd, char __user *, buf, size_t, count) |
| 100 | + { |
| 101 | ++#if defined(CONFIG_KSU) && !defined(CONFIG_KSU_KPROBES_HOOK) |
| 102 | ++ if (unlikely(ksu_vfs_read_hook)) |
| 103 | ++ ksu_handle_sys_read(fd, &buf, &count); |
| 104 | ++#endif |
| 105 | + return ksys_read(fd, buf, count); |
| 106 | + } |
| 107 | + |
| 108 | +diff --git a/fs/stat.c b/fs/stat.c |
| 109 | +index daf28da335cd..3fa40c6d7446 100644 |
| 110 | +--- a/fs/stat.c |
| 111 | ++++ b/fs/stat.c |
| 112 | +@@ -478,6 +478,12 @@ SYSCALL_DEFINE2(newlstat, const char __user *, filename, |
| 113 | + return cp_new_stat(&stat, statbuf); |
| 114 | + } |
| 115 | + |
| 116 | ++#if defined(CONFIG_KSU) && !defined(CONFIG_KSU_KPROBES_HOOK) |
| 117 | ++__attribute__((hot)) |
| 118 | ++extern int ksu_handle_stat(int *dfd, const char __user **filename_user, |
| 119 | ++ int *flags); |
| 120 | ++#endif |
| 121 | ++ |
| 122 | + #if !defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_SYS_NEWFSTATAT) |
| 123 | + SYSCALL_DEFINE4(newfstatat, int, dfd, const char __user *, filename, |
| 124 | + struct stat __user *, statbuf, int, flag) |
| 125 | +@@ -485,6 +491,9 @@ SYSCALL_DEFINE4(newfstatat, int, dfd, const char __user *, filename, |
| 126 | + struct kstat stat; |
| 127 | + int error; |
| 128 | + |
| 129 | ++#if defined(CONFIG_KSU) && !defined(CONFIG_KSU_KPROBES_HOOK) |
| 130 | ++ ksu_handle_stat(&dfd, &filename, &flag); |
| 131 | ++#endif |
| 132 | + error = vfs_fstatat(dfd, filename, &stat, flag); |
| 133 | + if (error) |
| 134 | + return error; |
| 135 | +@@ -636,6 +645,9 @@ SYSCALL_DEFINE4(fstatat64, int, dfd, const char __user *, filename, |
| 136 | + struct kstat stat; |
| 137 | + int error; |
| 138 | + |
| 139 | ++#if defined(CONFIG_KSU) && !defined(CONFIG_KSU_KPROBES_HOOK) // 32-bit su |
| 140 | ++ ksu_handle_stat(&dfd, &filename, &flag); |
| 141 | ++#endif |
| 142 | + error = vfs_fstatat(dfd, filename, &stat, flag); |
| 143 | + if (error) |
| 144 | + return error; |
| 145 | + |
0 commit comments