Skip to content
Draft
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d62e51d
actions: quote shell vars
5ec1cff Nov 1, 2024
5a6710c
actions: setup my sign key
5ec1cff Nov 2, 2024
17ef0d4
actions: use var for chat id
5ec1cff Nov 23, 2024
9283be8
actions: add more path to trigger build manager when pull request
5ec1cff Nov 6, 2025
e2d77f1
ksubot: make MESSAGE_THREAD_ID optional
5ec1cff Nov 23, 2024
5197bda
ksubot: collect all commits
5ec1cff Sep 7, 2025
b3ae1e9
ksubot: add upstream diff
5ec1cff Nov 6, 2025
be4de9e
add switch to init pgrp
5ec1cff Nov 13, 2025
afb601c
feature: allow shell & enable adbd
5ec1cff Nov 19, 2025
45bb08b
ci: Add workflow_dispatch trigger to build-manager
5ec1cff Dec 15, 2025
6d34240
kernel: allow use with official manager
5ec1cff Dec 22, 2025
9c41820
CONFIG_KSU=m
5ec1cff Dec 22, 2025
53393e8
also generate compdb for kernel source code
5ec1cff Dec 22, 2025
9d886fe
use syscall table hook
5ec1cff Dec 21, 2025
d4a0146
try blacklist mkp
5ec1cff Jan 2, 2026
1e0e936
inline hook tracepoint
5ec1cff Feb 25, 2026
b62a9bf
fix cfi
5ec1cff Feb 25, 2026
93eeec0
make more functions non-atomic-context
5ec1cff Feb 25, 2026
d5c9a41
use aarch64_addr_write to modify memory
5ec1cff Feb 26, 2026
4acebc2
add ksu_patch_text
5ec1cff Feb 27, 2026
1651ebe
use fixmap
5ec1cff Feb 28, 2026
1d8e282
use stop_machine instead of stop_machine_cpuslocked
5ec1cff Feb 28, 2026
557e548
add comments about hooking tracepoint and ksu_patch_text
5ec1cff Feb 28, 2026
46f4080
fix modpost on kernel 5.x
5ec1cff Mar 1, 2026
60cceac
try disable stack protector
5ec1cff Mar 1, 2026
71c4543
workaround stack protector
5ec1cff Mar 1, 2026
6667847
sync with upstream
5ec1cff Nov 19, 2025
edfcfbe
kernel: allowlist: remove allow_list_arr and allow_list_bitmap
5ec1cff Mar 9, 2026
0d4ff56
kernel: allowlist: make current_uid as the only key
5ec1cff Mar 9, 2026
258719d
kernel: allowlist: rename current_uid to curr_uid to avoid conflict w…
5ec1cff Mar 9, 2026
9abff30
kernel: allowlist: use hashtable
5ec1cff Mar 9, 2026
19ee493
fix count
5ec1cff Mar 9, 2026
c6d7c36
fix curr_uid
5ec1cff Mar 9, 2026
9b1b0f2
1
5ec1cff Mar 9, 2026
bc30b5b
static
5ec1cff Mar 9, 2026
a6120e4
kernel: allowlist: use kref to manage perm_data
5ec1cff Mar 9, 2026
d4be1ff
1
5ec1cff Mar 9, 2026
db4f97b
2
5ec1cff Mar 9, 2026
e2542c4
put first, then free
5ec1cff Mar 9, 2026
f1e4536
use rcu_dereference_protected and rcu_assign_pointer
5ec1cff Mar 9, 2026
8f6df4b
fix ksu_persistent_allow_list not called find_vpid with rcu
5ec1cff Mar 9, 2026
d2dfcba
format
5ec1cff Mar 9, 2026
868e0e0
kref_get_unless_zero
5ec1cff Mar 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-lkm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
jobs:
build-lkm:
strategy:
fail-fast: false
matrix:
kmi:
- android12-5.10
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/build-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ on:
- '.github/workflows/build-manager.yml'
- '.github/workflows/build-lkm.yml'
- '.github/workflows/ksud.yml'
- '.github/workflows/ddl-lkm.yml'
- 'manager/**'
- 'kernel/**'
- 'userspace/**'
- 'scripts/ksubot.py'
pull_request:
branches: [ "main", "dev" ]
paths:
- '.github/workflows/build-manager.yml'
- '.github/workflows/build-lkm.yml'
- '.github/workflows/ksud.yml'
- '.github/workflows/ddl-lkm.yml'
- 'manager/**'
- 'kernel/**'
- 'userspace/**'
- 'scripts/ksubot.py'
workflow_call:
workflow_dispatch:

jobs:
build-lkm:
Expand Down Expand Up @@ -79,14 +84,14 @@ jobs:
- name: Setup need_upload
id: need_upload
run: |
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
if [ ! -z "${{ secrets.BOT_TOKEN }}" ] && [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
echo "UPLOAD=true" >> $GITHUB_OUTPUT
else
echo "UPLOAD=false" >> $GITHUB_OUTPUT
fi

- name: Write key
if: ${{ ( github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' )) || github.ref_type == 'tag' }}
if: ${{ github.event_name != 'pull_request' || github.ref_type == 'tag' }}
run: |
if [ ! -z "${{ secrets.KEYSTORE }}" ]; then
{
Expand All @@ -95,7 +100,7 @@ jobs:
echo KEY_PASSWORD='${{ secrets.KEY_PASSWORD }}'
echo KEYSTORE_FILE='key.jks'
} >> gradle.properties
echo ${{ secrets.KEYSTORE }} | base64 -d > key.jks
echo "${{ secrets.KEYSTORE }}" | base64 -d > key.jks
fi

- name: Setup Java
Expand Down Expand Up @@ -157,11 +162,10 @@ jobs:
- name: Upload to telegram
if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true'
env:
CHAT_ID: ${{ secrets.CHAT_ID }}
CHAT_ID: ${{ vars.CHAT_ID }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
MESSAGE_THREAD_ID: ${{ secrets.MESSAGE_THREAD_ID }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
COMMIT_URL: ${{ github.event.head_commit.url }}
MESSAGE_THREAD_ID: ${{ vars.MESSAGE_THREAD_ID }}
GITHUB_EVENT: ${{ toJson(github.event) }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
TITLE: Manager
BRANCH: ${{ github.ref_name }}
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/ddk-lkm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ jobs:

cd kernel

if [[ "${{ inputs.kmi }}" == *"5.1"* ]]; then
echo "=== fix modpost ==="
sed -i '/s->module = exp->module;/s/^/\/\//' /opt/ddk/src/*/scripts/mod/modpost.c
pushd /opt/ddk/kdir/*
CMD_O=$(grep 'cmd_scripts/mod/modpost.o := ' scripts/mod/.modpost.o.cmd | sed 's/cmd_scripts\/mod\/modpost.o := //g')
CMD_2=$(grep 'cmd_scripts/mod/file2alias.o := ' scripts/mod/.file2alias.o.cmd | sed 's/cmd_scripts\/mod\/file2alias.o := //g')
CMD_3=$(grep 'cmd_scripts/mod/sumversion.o := ' scripts/mod/.sumversion.o.cmd | sed 's/cmd_scripts\/mod\/sumversion.o := //g')
CMD_L=$(grep 'cmd_scripts/mod/modpost := ' scripts/mod/.modpost.cmd | sed 's/cmd_scripts\/mod\/modpost := //g')
$CMD_O
$CMD_2
$CMD_3
$CMD_L
popd
fi

echo "=== Building kernelsu.ko for KMI: ${{ inputs.kmi }} ==="

CONFIG_KSU=m CC=clang make
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.idea
.vscode
/.vscode
CLAUDE.md
AGENTS.md
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
**English** | [Español](README_ES.md) | [简体中文](README_CN.md) | [繁體中文](README_TW.md) | [日本語](README_JP.md) | [한국어](README_KR.md) | [Polski](README_PL.md) | [Português (Brasil)](README_PT-BR.md) | [Türkçe](README_TR.md) | [Русский](README_RU.md) | [Tiếng Việt](README_VI.md) | [Indonesia](README_ID.md) | [עברית](README_IW.md) | [हिंदी](README_IN.md) | [Italiano](README_IT.md)

# KernelSU
# My KernelSU

<img src="https://kernelsu.org/logo.png" style="width: 96px;" alt="logo">

A kernel-based root solution for Android devices.
A [KernelSU](https://github.com/tiann/KernelSU/commit/423eefe38598ba8090bdc43144e7d5d25a412031)-based root solution for Android devices.

[![Latest release](https://img.shields.io/github/v/release/tiann/KernelSU?label=Release&logo=github)](https://github.com/tiann/KernelSU/releases/latest)
[![Weblate](https://img.shields.io/badge/Localization-Weblate-teal?logo=weblate)](https://hosted.weblate.org/engage/kernelsu)
Expand Down
2 changes: 1 addition & 1 deletion kernel/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ compile_commands.json
*.mod.c
*.symvers*
*.order
.*.ko.cmd
.*.cmd
.tmp_versions/
libs/
obj/
Expand Down
2 changes: 2 additions & 0 deletions kernel/.vscode/generate_compdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def gen_compile_commands(cmd_file_search_path, out_dir):

if not cmd_file_search_path:
cmd_file_search_path = [out_dir]
else:
cmd_file_search_path += [out_dir]

cmd_files = []
for search_path in cmd_file_search_path:
Expand Down
42 changes: 39 additions & 3 deletions kernel/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ kernelsu-objs += feature.o
kernelsu-objs += ksud.o
kernelsu-objs += seccomp_cache.o
kernelsu-objs += file_wrapper.o
kernelsu-objs += util.o
kernelsu-objs += pte.o
kernelsu-objs += patch.o
kernelsu-objs += inline_hook.o
kernelsu-objs += trampoline.o

kernelsu-objs += selinux/selinux.o
kernelsu-objs += selinux/sepolicy.o
Expand Down Expand Up @@ -60,12 +63,35 @@ $(warning "KSU_GIT_VERSION not defined! It is better to make KernelSU a git repo
ccflags-y += -DKSU_VERSION=16
endif

KSU_NEW_DCACHE_FLUSH := $(shell grep -q __flush_dcache_area $(srctree)/arch/arm64/include/asm/cacheflush.h ; echo $$?)
$(info -- KSU_NEW_DCACHE_FLUSH: $(KSU_NEW_DCACHE_FLUSH))

KSU_MTE_SYNC_TAGS_DEF := $(shell grep 'void mte_sync_tags' $(srctree)/arch/arm64/include/asm/mte.h | grep -v 'static inline')
# 6.6
KSU_MTE_SYNC_TAGS_NR_PAGES := $(shell echo '$(KSU_MTE_SYNC_TAGS_DEF)' | grep -q 'nr_pages' && echo 1 || echo 0)
# 6.1
KSU_MTE_SYNC_TAGS_NORMAL := $(shell echo '$(KSU_MTE_SYNC_TAGS_DEF)' | grep -q '(pte_t pte)' && echo 1 || echo 0)
# 13-5.10
KSU_MTE_SYNC_TAGS_OLD_PTE := $(shell echo '$(KSU_MTE_SYNC_TAGS_DEF)' | grep -q 'old_pte' && echo 1 || echo 0)
# 12-5.10
KSU_MTE_SYNC_TAGS_PTEP := $(shell echo '$(KSU_MTE_SYNC_TAGS_DEF)' | grep -q '*ptep' && echo 1 || echo 0)
KSU_DEF_MTE_SYNC_TAGS := 'extern $(KSU_MTE_SYNC_TAGS_DEF)'

$(info -- KSU_DEF_MTE_SYNC_TAGS: $(KSU_DEF_MTE_SYNC_TAGS))
$(info -- KSU_MTE_SYNC_TAGS_NR_PAGES: $(KSU_MTE_SYNC_TAGS_NR_PAGES))
$(info -- KSU_MTE_SYNC_TAGS_PTEP: $(KSU_MTE_SYNC_TAGS_PTEP))
$(info -- KSU_MTE_SYNC_TAGS_OLD_PTE: $(KSU_MTE_SYNC_TAGS_OLD_PTE))
$(info -- KSU_MTE_SYNC_TAGS_NORMAL: $(KSU_MTE_SYNC_TAGS_NORMAL))

OFFICIAL_EXPECTED_SIZE := 0x033b
OFFICIAL_EXPECTED_HASH := c371061b19d8c7d7d6133c6a9bafe198fa944e50c1b31c9d8daa8d7f1fc2d2d6

ifndef KSU_EXPECTED_SIZE
KSU_EXPECTED_SIZE := 0x033b
KSU_EXPECTED_SIZE := 384
endif

ifndef KSU_EXPECTED_HASH
KSU_EXPECTED_HASH := c371061b19d8c7d7d6133c6a9bafe198fa944e50c1b31c9d8daa8d7f1fc2d2d6
KSU_EXPECTED_HASH := 7e0c6d7278a3bb8e364e0fcba95afaf3666cf5ff3c245a3b63c8833bd0445cc4
endif

ifdef KSU_MANAGER_PACKAGE
Expand All @@ -78,6 +104,16 @@ $(info -- KernelSU Manager signature hash: $(KSU_EXPECTED_HASH))

ccflags-y += -DEXPECTED_SIZE=$(KSU_EXPECTED_SIZE)
ccflags-y += -DEXPECTED_HASH=\"$(KSU_EXPECTED_HASH)\"
ccflags-y += -DOFFICIAL_EXPECTED_SIZE=$(OFFICIAL_EXPECTED_SIZE)
ccflags-y += -DOFFICIAL_EXPECTED_HASH=\"$(OFFICIAL_EXPECTED_HASH)\"

ccflags-y += -DKSU_NEW_DCACHE_FLUSH=$(KSU_NEW_DCACHE_FLUSH)

ccflags-y += -DKSU_DEF_MTE_SYNC_TAGS=$(KSU_DEF_MTE_SYNC_TAGS)
ccflags-y += -DKSU_MTE_SYNC_TAGS_NR_PAGES=$(KSU_MTE_SYNC_TAGS_NR_PAGES)
ccflags-y += -DKSU_MTE_SYNC_TAGS_PTEP=$(KSU_MTE_SYNC_TAGS_PTEP)
ccflags-y += -DKSU_MTE_SYNC_TAGS_OLD_PTE=$(KSU_MTE_SYNC_TAGS_OLD_PTE)
ccflags-y += -DKSU_MTE_SYNC_TAGS_NORMAL=$(KSU_MTE_SYNC_TAGS_NORMAL)

ccflags-y += -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat -Wno-missing-prototypes
ccflags-y += -Wno-declaration-after-statement -Wno-unused-function
Expand Down
2 changes: 1 addition & 1 deletion kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $(info -- MDIR: $(MDIR))
.PHONY: all compdb clean format check-format

all: check_symbol
make -C $(KDIR) M=$(MDIR) modules
CONFIG_KSU=m make -C $(KDIR) M=$(MDIR) modules
./check_symbol kernelsu.ko $(KDIR)/vmlinux
compdb:
python3 $(MDIR)/.vscode/generate_compdb.py -O $(KDIR) $(MDIR)
Expand Down
Loading