|
| 1 | +diff --git a/drivers/input/input.c b/drivers/input/input.c |
| 2 | +index 171f71bd4..8258f0a30 100644 |
| 3 | +--- a/drivers/input/input.c |
| 4 | ++++ b/drivers/input/input.c |
| 5 | +@@ -446,11 +446,21 @@ static 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 | ++#ifdef CONFIG_KSU |
| 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 | ++#ifdef CONFIG_KSU |
| 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 b1b9db56a..9748c2315 100644 |
| 29 | +--- a/fs/exec.c |
| 30 | ++++ b/fs/exec.c |
| 31 | +@@ -2031,12 +2031,22 @@ int kernel_execve(const char *kernel_filename, |
| 32 | + return retval; |
| 33 | + } |
| 34 | + |
| 35 | ++#ifdef CONFIG_KSU |
| 36 | ++__attribute__((hot)) |
| 37 | ++extern int ksu_handle_execveat(int *fd, |
| 38 | ++ struct filename **filename_ptr, |
| 39 | ++ void *argv, void *envp, int *flags); |
| 40 | ++#endif |
| 41 | ++ |
| 42 | + static int do_execve(struct filename *filename, |
| 43 | + const char __user *const __user *__argv, |
| 44 | + const char __user *const __user *__envp) |
| 45 | + { |
| 46 | + struct user_arg_ptr argv = { .ptr.native = __argv }; |
| 47 | + struct user_arg_ptr envp = { .ptr.native = __envp }; |
| 48 | ++#ifdef CONFIG_KSU |
| 49 | ++ ksu_handle_execveat((int *)AT_FDCWD, &filename, &argv, &envp, 0); |
| 50 | ++#endif |
| 51 | + return do_execveat_common(AT_FDCWD, filename, argv, envp, 0); |
| 52 | + } |
| 53 | + |
| 54 | +@@ -2064,6 +2074,9 @@ static int compat_do_execve(struct filename *filename, |
| 55 | + .is_compat = true, |
| 56 | + .ptr.compat = __envp, |
| 57 | + }; |
| 58 | ++#ifdef CONFIG_KSU // 32-bit su and 32-on-64 support |
| 59 | ++ ksu_handle_execveat((int *)AT_FDCWD, &filename, &argv, &envp, 0); |
| 60 | ++#endif |
| 61 | + return do_execveat_common(AT_FDCWD, filename, argv, envp, 0); |
| 62 | + } |
| 63 | + |
| 64 | +diff --git a/fs/open.c b/fs/open.c |
| 65 | +index 39779f1ba..bef45143c 100644 |
| 66 | +--- a/fs/open.c |
| 67 | ++++ b/fs/open.c |
| 68 | +@@ -466,8 +466,17 @@ static long do_faccessat(int dfd, const char __user *filename, int mode, int fla |
| 69 | + return res; |
| 70 | + } |
| 71 | + |
| 72 | ++#ifdef CONFIG_KSU |
| 73 | ++__attribute__((hot)) |
| 74 | ++extern int ksu_handle_faccessat(int *dfd, const char __user **filename_user, |
| 75 | ++ int *mode, int *flags); |
| 76 | ++#endif |
| 77 | ++ |
| 78 | + SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode) |
| 79 | + { |
| 80 | ++#ifdef CONFIG_KSU |
| 81 | ++ ksu_handle_faccessat(&dfd, &filename, &mode, NULL); |
| 82 | ++#endif |
| 83 | + return do_faccessat(dfd, filename, mode, 0); |
| 84 | + } |
| 85 | + |
| 86 | +diff --git a/fs/read_write.c b/fs/read_write.c |
| 87 | +index 3f6818620..b2a45d215 100644 |
| 88 | +--- a/fs/read_write.c |
| 89 | ++++ b/fs/read_write.c |
| 90 | +@@ -628,8 +628,18 @@ ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count) |
| 91 | + return ret; |
| 92 | + } |
| 93 | + |
| 94 | ++#ifdef CONFIG_KSU |
| 95 | ++extern bool ksu_vfs_read_hook __read_mostly; |
| 96 | ++extern int ksu_handle_sys_read(unsigned int fd, char __user **buf_ptr, |
| 97 | ++ size_t *count_ptr); |
| 98 | ++#endif |
| 99 | ++ |
| 100 | + SYSCALL_DEFINE3(read, unsigned int, fd, char __user *, buf, size_t, count) |
| 101 | + { |
| 102 | ++#ifdef CONFIG_KSU |
| 103 | ++ if (unlikely(ksu_vfs_read_hook)) |
| 104 | ++ ksu_handle_sys_read(fd, &buf, &count); |
| 105 | ++#endif |
| 106 | + return ksys_read(fd, buf, count); |
| 107 | + } |
| 108 | + |
| 109 | +diff --git a/fs/stat.c b/fs/stat.c |
| 110 | +index 357a1db41..d5087ca1f 100644 |
| 111 | +--- a/fs/stat.c |
| 112 | ++++ b/fs/stat.c |
| 113 | +@@ -401,6 +401,12 @@ SYSCALL_DEFINE2(newlstat, const char __user *, filename, |
| 114 | + return cp_new_stat(&stat, statbuf); |
| 115 | + } |
| 116 | + |
| 117 | ++#ifdef CONFIG_KSU |
| 118 | ++__attribute__((hot)) |
| 119 | ++extern int ksu_handle_stat(int *dfd, const char __user **filename_user, |
| 120 | ++ int *flags); |
| 121 | ++#endif |
| 122 | ++ |
| 123 | + #if !defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_SYS_NEWFSTATAT) |
| 124 | + SYSCALL_DEFINE4(newfstatat, int, dfd, const char __user *, filename, |
| 125 | + struct stat __user *, statbuf, int, flag) |
| 126 | +@@ -408,6 +414,9 @@ SYSCALL_DEFINE4(newfstatat, int, dfd, const char __user *, filename, |
| 127 | + struct kstat stat; |
| 128 | + int error; |
| 129 | + |
| 130 | ++#ifdef CONFIG_KSU |
| 131 | ++ ksu_handle_stat(&dfd, &filename, &flag); |
| 132 | ++#endif |
| 133 | + error = vfs_fstatat(dfd, filename, &stat, flag); |
| 134 | + if (error) |
| 135 | + return error; |
| 136 | +@@ -559,6 +568,9 @@ SYSCALL_DEFINE4(fstatat64, int, dfd, const char __user *, filename, |
| 137 | + struct kstat stat; |
| 138 | + int error; |
| 139 | + |
| 140 | ++#ifdef CONFIG_KSU // 32-bit su |
| 141 | ++ ksu_handle_stat(&dfd, &filename, &flag); |
| 142 | ++#endif |
| 143 | + error = vfs_fstatat(dfd, filename, &stat, flag); |
| 144 | + if (error) |
| 145 | + return error; |
| 146 | +-- |
| 147 | +2.34.1 |
| 148 | + |
0 commit comments