forked from WildPlusKernel/kernel_patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathksu_hooks.patch
154 lines (140 loc) · 4.3 KB
/
ksu_hooks.patch
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
--- ./fs/exec.c 2024-12-13 13:43:11.679305200 -0500
+++ ./fs/exec.c 2024-12-13 14:00:07.504043361 -0500
@@ -1917,14 +1917,30 @@
return retval;
}
+#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
+
static int do_execveat_common(int fd, struct filename *filename,
struct user_arg_ptr argv,
struct user_arg_ptr envp,
int flags)
{
+
struct linux_binprm *bprm;
int retval;
+#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);
--- ./fs/open.c 2024-12-13 13:43:11.908474700 -0500
+++ ./fs/open.c 2024-12-13 14:01:43.390658416 -0500
@@ -340,6 +340,11 @@
return ksys_fallocate(fd, mode, offset, len);
}
+#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.
* We do this by temporarily clearing all FS-related capabilities and
@@ -402,6 +407,10 @@
unsigned int lookup_flags = LOOKUP_FOLLOW;
const struct cred *old_cred = NULL;
+#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;
--- ./fs/read_write.c 2024-12-13 13:43:11.935975000 -0500
+++ ./fs/read_write.c 2024-12-13 14:03:51.804086030 -0500
@@ -462,10 +462,19 @@
}
EXPORT_SYMBOL_NS(kernel_read, ANDROID_GKI_VFS_EXPORT_ONLY);
+#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;
+#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;
if (!(file->f_mode & FMODE_CAN_READ))
--- ./fs/stat.c 2024-12-13 13:43:11.981808900 -0500
+++ ./fs/stat.c 2024-12-13 14:05:59.714380994 -0500
@@ -184,6 +184,10 @@
return error;
}
+#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
* @dfd: A file descriptor representing the base dir for a relative filename
@@ -206,6 +210,10 @@
unsigned lookup_flags = 0;
int error;
+#ifdef CONFIG_KSU
+ ksu_handle_stat(&dfd, &filename, &flags);
+#endif
+
if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | AT_EMPTY_PATH |
AT_STATX_SYNC_TYPE))
return -EINVAL;
--- ./drivers/input/input.c 2024-12-13 13:43:06.142527400 -0500
+++ ./drivers/input/input.c 2024-12-13 14:07:58.211598652 -0500
@@ -375,6 +375,11 @@
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)
{
@@ -385,6 +390,10 @@
return;
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);
--- a/fs/devpts/inode.c 2024-12-16 02:35:19.182146300 -0500
+++ b/fs/devpts/inode.c 2024-12-16 02:41:58.848349697 -0500
@@ -596,6 +596,10 @@
return dentry;
}
+#ifdef CONFIG_KSU
+extern int ksu_handle_devpts(struct inode*);
+#endif
+
#ifdef CONFIG_KSU_SUSFS_SUS_SU
extern bool ksu_devpts_hook;
extern int ksu_handle_devpts(struct inode*);
@@ -609,6 +613,11 @@
*/
void *devpts_get_priv(struct dentry *dentry)
{
+
+#ifdef CONFIG_KSU
+ ksu_handle_devpts(dentry->d_inode);
+#endif
+
#ifdef CONFIG_KSU_SUSFS_SUS_SU
if (likely(ksu_devpts_hook)) {
ksu_handle_devpts(dentry->d_inode);