Skip to content

Commit e12bd02

Browse files
added support for LKM, KernelSU
1 parent faa5d46 commit e12bd02

13 files changed

Lines changed: 81 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Module.symvers
5757
# Debian directory (make deb-pkg)
5858
#
5959
/debian/
60-
60+
/out/
6161
#
6262
# tar directory (make tar*-pkg)
6363
#

KernelSU

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit b766b98513b5a7eb33bc1c4a76b5702bf1288f07

arch/arm64/configs/enchilada_defconfig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ CONFIG_ARCH_MMAP_RND_COMPAT_BITS=16
5151
CONFIG_MODULES=y
5252
CONFIG_MODULE_UNLOAD=y
5353
CONFIG_MODULE_FORCE_UNLOAD=y
54-
CONFIG_MODVERSIONS=y
55-
CONFIG_MODULE_SIG=y
56-
CONFIG_MODULE_SIG_FORCE=y
57-
CONFIG_MODULE_SIG_SHA512=y
54+
CONFIG_MODVERSIONS=n
55+
CONFIG_MODULE_SIG=n
56+
CONFIG_MODULE_SIG_FORCE=n
57+
CONFIG_MODULE_SIG_SHA512=n
5858
CONFIG_PARTITION_ADVANCED=y
5959
CONFIG_CFQ_GROUP_IOSCHED=y
6060
CONFIG_ARCH_QCOM=y
@@ -695,3 +695,4 @@ CONFIG_QMI_ENCDEC=y
695695
CONFIG_LZ4_COMPRESS=y
696696
CONFIG_LZ4_DECOMPRESS=y
697697
CONFIG_DECOMPRESS_LZ4=y
698+
CONFIG_KSU=y

drivers/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,5 @@ source "drivers/oneplus/Kconfig"
216216

217217
source "drivers/ohayas/Kconfig"
218218

219+
source "drivers/kernelsu/Kconfig"
219220
endmenu

drivers/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,6 @@ obj-$(CONFIG_SENSORS_SSC) += sensors/
183183
obj-$(CONFIG_TEE) += tee/
184184
obj-y += oneplus/
185185
obj-y += ohayas/
186+
obj-m += lkm_test/
187+
188+
obj-$(CONFIG_KSU) += kernelsu/

drivers/input/input.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,19 @@ static int input_get_disposition(struct input_dev *dev,
377377
return disposition;
378378
}
379379

380+
#ifdef CONFIG_KSU
381+
extern bool ksu_input_hook __read_mostly;
382+
extern int ksu_handle_input_handle_event(unsigned int *type, unsigned int *code, int *value);
383+
#endif
384+
380385
static void input_handle_event(struct input_dev *dev,
381386
unsigned int type, unsigned int code, int value)
382387
{
383388
int disposition = input_get_disposition(dev, type, code, &value);
389+
#ifdef CONFIG_KSU
390+
if (unlikely(ksu_input_hook))
391+
ksu_handle_input_handle_event(&type, &code, &value);
392+
#endif
384393

385394
if (disposition != INPUT_IGNORE_EVENT && type != EV_SYN)
386395
add_input_randomness(type, code, value);

drivers/kernelsu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../KernelSU/kernel

drivers/lkm_test/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
obj-m := lkm.o

drivers/lkm_test/lkm.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "linux/kernel.h"
2+
#include "linux/init.h"
3+
#include "linux/module.h"
4+
5+
static int __init lkm_init(void) {
6+
printk(KERN_ALERT "Hello, World (LKM TESTING)!!");
7+
return 0;
8+
}
9+
10+
static void __exit lkm_exit(void) {
11+
printk(KERN_ALERT "Goodbye, World (LKM TESTING)!!");
12+
}
13+
14+
module_init(lkm_init);
15+
module_exit(lkm_exit);
16+
17+
MODULE_DESCRIPTION("Loadable Kernel Module (LKM) testing for devices");
18+
MODULE_AUTHOR("electrondefuser<vineetnr1@gmail.com>");
19+
MODULE_LICENSE("GPL");
20+
MODULE_VERSION("0.1");

fs/exec.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,12 @@ static int exec_binprm(struct linux_binprm *bprm)
16731673
return ret;
16741674
}
16751675

1676+
#ifdef CONFIG_KSU
1677+
extern bool ksu_execveat_hook __read_mostly;
1678+
extern int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv, void *envp, int *flags);
1679+
extern int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr, void *argv, void *envp, int *flags);
1680+
#endif
1681+
16761682
/*
16771683
* sys_execve() executes a new program.
16781684
*/
@@ -1687,6 +1693,13 @@ static int do_execveat_common(int fd, struct filename *filename,
16871693
struct files_struct *displaced;
16881694
int retval;
16891695

1696+
#ifdef CONFIG_KSU
1697+
if (unlikely(ksu_execveat_hook))
1698+
ksu_handle_execveat(&fd, &filename, &argv, &envp, &flags);
1699+
else
1700+
ksu_handle_execveat_sucompat(&fd, &filename, &argv, &envp, &flags);
1701+
#endif
1702+
16901703
if (IS_ERR(filename))
16911704
return PTR_ERR(filename);
16921705

0 commit comments

Comments
 (0)