Skip to content

Commit 5f75588

Browse files
committed
drivers/kernelsu: port KernelSU NEXT
1 parent b867ad6 commit 5f75588

36 files changed

+6628
-0
lines changed

drivers/kernelsu/.check

Whitespace-only changes.

drivers/kernelsu/.clang-format

Lines changed: 548 additions & 0 deletions
Large diffs are not rendered by default.

drivers/kernelsu/.clangd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Diagnostics:
2+
UnusedIncludes: Strict
3+
ClangTidy:
4+
Remove: bugprone-sizeof-expression

drivers/kernelsu/.version

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

drivers/kernelsu/Kconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
menu "KernelSU"
2+
3+
config KSU
4+
tristate "KernelSU function support"
5+
depends on OVERLAY_FS
6+
default y
7+
help
8+
Enable kernel-level root privileges on Android System.
9+
To compile as a module, choose M here: the
10+
module will be called kernelsu.
11+
12+
config KSU_DEBUG
13+
bool "KernelSU debug mode"
14+
depends on KSU
15+
default n
16+
help
17+
Enable KernelSU debug mode.
18+
19+
endmenu

drivers/kernelsu/LICENSE

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

drivers/kernelsu/Makefile

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
kernelsu-objs := ksu.o
2+
kernelsu-objs += allowlist.o
3+
kernelsu-objs += apk_sign.o
4+
kernelsu-objs += sucompat.o
5+
kernelsu-objs += throne_tracker.o
6+
kernelsu-objs += core_hook.o
7+
kernelsu-objs += ksud.o
8+
kernelsu-objs += embed_ksud.o
9+
kernelsu-objs += kernel_compat.o
10+
11+
kernelsu-objs += selinux/selinux.o
12+
kernelsu-objs += selinux/sepolicy.o
13+
kernelsu-objs += selinux/rules.o
14+
ccflags-y += -I$(srctree)/security/selinux -I$(srctree)/security/selinux/include
15+
ccflags-y += -I$(objtree)/security/selinux -include $(srctree)/include/uapi/asm-generic/errno.h
16+
17+
obj-$(CONFIG_KSU) += kernelsu.o
18+
19+
# .git is a text file while the module is imported by 'git submodule add'.
20+
ifeq ($(shell test -e $(srctree)/$(src)/../.git; echo $$?),0)
21+
$(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin [ -f ../.git/shallow ] && git fetch --unshallow)
22+
KSU_GIT_VERSION := $(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin git rev-list --count HEAD)
23+
# ksu_version: major * 10000 + git version + 200 for historical reasons
24+
$(eval KSU_VERSION=$(shell expr 10000 + $(KSU_GIT_VERSION) + 200))
25+
$(info -- KernelSU version: $(KSU_VERSION))
26+
else # If there is no .git file, the default version will be passed.
27+
endif
28+
29+
ifeq ($(shell grep -q " current_sid(void)" $(srctree)/security/selinux/include/objsec.h; echo $$?),0)
30+
ccflags-y += -DKSU_COMPAT_HAS_CURRENT_SID
31+
endif
32+
33+
ifeq ($(shell grep -q "struct selinux_state " $(srctree)/security/selinux/include/security.h; echo $$?),0)
34+
ccflags-y += -DKSU_COMPAT_HAS_SELINUX_STATE
35+
endif
36+
37+
ifndef KSU_EXPECTED_SIZE
38+
KSU_EXPECTED_SIZE := 0x033b
39+
endif
40+
41+
ifndef KSU_EXPECTED_HASH
42+
KSU_EXPECTED_HASH := c371061b19d8c7d7d6133c6a9bafe198fa944e50c1b31c9d8daa8d7f1fc2d2d6
43+
endif
44+
45+
ifdef KSU_MANAGER_PACKAGE
46+
ccflags-y += -DKSU_MANAGER_PACKAGE=\"$(KSU_MANAGER_PACKAGE)\"
47+
$(info -- KernelSU Manager package name: $(KSU_MANAGER_PACKAGE))
48+
endif
49+
50+
$(info -- KernelSU Manager signature size: $(KSU_EXPECTED_SIZE))
51+
$(info -- KernelSU Manager signature hash: $(KSU_EXPECTED_HASH))
52+
53+
ccflags-y += -DEXPECTED_SIZE=$(KSU_EXPECTED_SIZE)
54+
ccflags-y += -DEXPECTED_HASH=\"$(KSU_EXPECTED_HASH)\"
55+
56+
ifeq ($(shell grep -q "int path_umount" $(srctree)/fs/namespace.c; echo $$?),0)
57+
ccflags-y += -DKSU_UMOUNT
58+
else
59+
$(info -- Did you know you can backport path_umount to fs/namespace.c from 5.9?)
60+
$(info -- Read: https://kernelsu.org/guide/how-to-integrate-for-non-gki.html#how-to-backport-path-umount)
61+
endif
62+
63+
ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat
64+
ccflags-y += -Wno-declaration-after-statement -Wno-unused-function
65+
66+
# Keep a new line here!! Because someone may append config
67+
68+
ccflags-y += -DKSU_VERSION=12030

0 commit comments

Comments
 (0)