forked from topnotchfreaks/kernel_patches
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path0001-SUSFS-syscall-hooks.patch
More file actions
158 lines (144 loc) · 5.1 KB
/
0001-SUSFS-syscall-hooks.patch
File metadata and controls
158 lines (144 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
--- a/fs/exec.c 2025-02-25 16:26:47.929599800 -0500
+++ b/fs/exec.c 2025-02-25 16:31:09.392181069 -0500
@@ -2025,12 +2025,26 @@
return retval;
}
+#if defined(CONFIG_KSU) && defined(CONFIG_KSU_MANUAL_HOOK)
+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
+
static int do_execve(struct filename *filename,
const char __user *const __user *__argv,
const char __user *const __user *__envp)
{
struct user_arg_ptr argv = { .ptr.native = __argv };
struct user_arg_ptr envp = { .ptr.native = __envp };
+#if defined(CONFIG_KSU) && defined(CONFIG_KSU_MANUAL_HOOK)
+ if (unlikely(ksu_execveat_hook))
+ ksu_handle_execveat((int *)AT_FDCWD, &filename, &argv, &envp, 0);
+ else
+ ksu_handle_execveat_sucompat((int *)AT_FDCWD, &filename, NULL, NULL, NULL);
+#endif
return do_execveat_common(AT_FDCWD, filename, argv, envp, 0);
}
@@ -2058,6 +2072,10 @@
.is_compat = true,
.ptr.compat = __envp,
};
+#if defined(CONFIG_KSU) && defined(CONFIG_KSU_MANUAL_HOOK)
+ if (!ksu_execveat_hook)
+ ksu_handle_execveat_sucompat((int *)AT_FDCWD, &filename, NULL, NULL, NULL); /* 32-bit su */
+#endif
return do_execveat_common(AT_FDCWD, filename, argv, envp, 0);
}
--- a/fs/open.c 2025-02-25 16:26:48.056318400 -0500
+++ b/fs/open.c 2025-02-25 16:33:35.583177999 -0500
@@ -466,8 +466,16 @@
return res;
}
+#if defined(CONFIG_KSU) && defined(CONFIG_KSU_MANUAL_HOOK)
+extern int ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode,
+ int *flags);
+#endif
+
SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode)
{
+#if defined(CONFIG_KSU) && defined(CONFIG_KSU_MANUAL_HOOK)
+ ksu_handle_faccessat(&dfd, &filename, &mode, NULL);
+#endif
return do_faccessat(dfd, filename, mode, 0);
}
--- a/fs/read_write.c 2025-02-25 16:26:48.085561100 -0500
+++ b/fs/read_write.c 2025-02-25 16:34:38.409673281 -0500
@@ -628,8 +628,18 @@
return ret;
}
+#if defined(CONFIG_KSU) && defined(CONFIG_KSU_MANUAL_HOOK)
+extern bool ksu_vfs_read_hook __read_mostly;
+extern int ksu_handle_sys_read(unsigned int fd, char __user **buf_ptr,
+ size_t *count_ptr);
+#endif
+
SYSCALL_DEFINE3(read, unsigned int, fd, char __user *, buf, size_t, count)
{
+#if defined(CONFIG_KSU) && defined(CONFIG_KSU_MANUAL_HOOK)
+ if (unlikely(ksu_vfs_read_hook))
+ ksu_handle_sys_read(fd, &buf, &count);
+#endif
return ksys_read(fd, buf, count);
}
--- a/fs/stat.c 2025-02-25 16:26:48.095308700 -0500
+++ b/fs/stat.c 2025-02-25 16:40:30.177700209 -0500
@@ -401,6 +401,10 @@
return cp_new_stat(&stat, statbuf);
}
+#if defined(CONFIG_KSU) && defined(CONFIG_KSU_MANUAL_HOOK)
+extern int ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags);
+#endif
+
#if !defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_SYS_NEWFSTATAT)
SYSCALL_DEFINE4(newfstatat, int, dfd, const char __user *, filename,
struct stat __user *, statbuf, int, flag)
@@ -408,6 +412,9 @@
struct kstat stat;
int error;
+#if defined(CONFIG_KSU) && defined(CONFIG_KSU_MANUAL_HOOK)
+ ksu_handle_stat(&dfd, &filename, &flag);
+#endif
error = vfs_fstatat(dfd, filename, &stat, flag);
if (error)
return error;
@@ -559,6 +566,9 @@
struct kstat stat;
int error;
+#if defined(CONFIG_KSU) && defined(CONFIG_COMPAT) && defined(CONFIG_KSU_MANUAL_HOOK)
+ ksu_handle_stat(&dfd, &filename, &flag); /* 32-bit su */
+#endif
error = vfs_fstatat(dfd, filename, &stat, flag);
if (error)
return error;
--- a/drivers/input/input.c 2025-02-25 16:26:13.021725500 -0500
+++ b/drivers/input/input.c 2025-02-25 16:47:15.869567274 -0500
@@ -446,11 +446,21 @@
* to 'seed' initial state of a switch or initial position of absolute
* axis, etc.
*/
+#if defined(CONFIG_KSU) && defined(CONFIG_KSU_MANUAL_HOOK)
+extern bool ksu_input_hook __read_mostly;
+extern int ksu_handle_input_handle_event(unsigned int *type, unsigned int *code, int *value);
+#endif
+
void input_event(struct input_dev *dev,
unsigned int type, unsigned int code, int value)
{
unsigned long flags;
+#if defined(CONFIG_KSU) && defined(CONFIG_KSU_MANUAL_HOOK)
+ if (unlikely(ksu_input_hook))
+ ksu_handle_input_handle_event(&type, &code, &value);
+#endif
+
if (is_event_supported(type, dev->evbit, EV_MAX)) {
spin_lock_irqsave(&dev->event_lock, flags);
--- a/drivers/tty/pty.c 2025-02-25 16:26:47.666415400 -0500
+++ b/drivers/tty/pty.c 2025-02-25 16:50:08.191037416 -0500
@@ -702,11 +702,18 @@
* This provides our locking for the tty pointer.
*/
+#if defined(CONFIG_KSU) && defined(CONFIG_KSU_MANUAL_HOOK)
+extern int ksu_handle_devpts(struct inode*);
+#endif
+
static struct tty_struct *pts_unix98_lookup(struct tty_driver *driver,
struct file *file, int idx)
{
struct tty_struct *tty;
+#if defined(CONFIG_KSU) && defined(CONFIG_KSU_MANUAL_HOOK)
+ ksu_handle_devpts((struct inode *)file->f_path.dentry->d_inode);
+#endif
mutex_lock(&devpts_mutex);
tty = devpts_get_priv(file->f_path.dentry);
mutex_unlock(&devpts_mutex);