Commit Graph

37 Commits

Author SHA1 Message Date
ShirkNeko
118fcf507a kernel: fmt 2025-11-18 21:39:31 +08:00
ShirkNeko
e79b702fd6 Synchronise some modifications
Co-authored-by: Ylarod <me@ylarod.cn>
Co-authored-by: 5ec1cff <56485584+5ec1cff@users.noreply.github.com>
Co-authored-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
Co-authored-by: u9521 <63995396+u9521@users.noreply.github.com>
Co-authored-by: Wang Han <416810799@qq.com>
Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
Co-authored-by: Faris <rissu.ntk@gmail.com>
2025-11-18 21:27:22 +08:00
ShirkNeko
722980e221 KernelSU: Fixed some susfs features mistakenly being set to default n in Kconfig
Co-authored-by: simonpunk <simonpunk2016@gmail.com>
2025-11-18 00:27:38 +08:00
ShirkNeko
4c04508267 kernel: Apply the susfs patch
Co-authored-by: simonpunk <simonpunk2016@gmail.com>
Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
2025-11-14 18:36:04 +08:00
ShirkNeko
66f37c7310 Revert "kernel: Apply the SUSFS patch"
This reverts commit ad0f3f6025.
2025-11-09 21:39:04 +08:00
ShirkNeko
ad0f3f6025 kernel: Apply the SUSFS patch 2025-11-09 18:32:16 +08:00
ShirkNeko
a525048d1f kernel: Remove susfs patch 2025-11-09 12:48:51 +08:00
ShirkNeko
3382574aad kernel: Resolve compilation issues 2025-11-06 14:50:46 +08:00
ShirkNeko
71353a70d4 kernel: use sys_enter tracepoint for sucompat (#533)
* use sys_enter tracepoint for sucompat

* update sucompat rules

* clean tif mark

* mark tif after load allow list

* clear all tif first, then mark target

* Fix shell su

* allow when escape

* fix bugs

* kernel: Resolve logical inconsistencies

---------

Co-authored-by: Ylarod <me@ylarod.cn>
Co-authored-by: weishu <twsxtd@gmail.com>
2025-11-06 14:34:45 +08:00
ShirkNeko
ab3ff2699c Revert "kernel: Remove CONFIG_KSU_MANUAL_SU protection"
This reverts commit fa229b23a4.
2025-11-05 01:50:00 +08:00
ShirkNeko
fa229b23a4 kernel: Remove CONFIG_KSU_MANUAL_SU protection 2025-11-04 21:48:06 +08:00
ShirkNeko
afc8b53ca6 new supercall impl (#511)
* refactor: replace throne tracker with ksud token

* use snprintf

* refactor: new supercall impl

- Import the sukisu command

* disable seccomp for supercall users

* kernel: fmt clear

* kernel: Enable macro protection for sulog

- Only enabled on kernel versions greater than 5.10.245

* kernel: Refactor kprobe hooks and implement LSM hooks for improved security handling

* debug mode

* kernel: Add functionality to generate and validate authentication tokens for cmd_su

* kernel: Simplified manual SU command processing for code

* kernel: replace renameat hook with fsnotify

* Revert "refactor: replace throne tracker with ksud token"

This reverts commit aa2cbbf.

* kernel: fix compile

* kernel: fix compile below 6.0

* Fix compile err; Add become_manager

* kernel: install fd for manager automaticlly

- extend to import the corresponding command

* manager: new supercall impl

* temp changes for ksud

* ksud: fix compile

* fix wrong opcode

* kernel: fix compile

* kernel: Fixed hook type and KPM status retrieval errors

* kernel: Fixed potential null pointer issue with current->mm in kernel version 5.10

When calling get_full_comm() within system call hooks, current->mm may be null (prctl). A fallback mechanism for current->comm must be added beforehand to prevent null pointer dereferences when accessing mm->arg_start/arg_end.

Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>

* ksud: fix cargo check

* manager: Fixed an issue where the KSUD release and user-mode scanning switch failed to function correctly.

- kernel: fix spin lock mutual

kernel: Fixed potential null pointer issue with current->mm in kernel version 5.10

When calling get_full_comm() within system call hooks, current->mm may be null (prctl). A fallback mechanism for current->comm must be added beforehand to prevent null pointer dereferences when accessing mm->arg_start/arg_end.

kernel: try introduce like susfs's method to fix prctl delay

* seccomp: allow reboot

* use u32

* update clang-format

* 4 spaces save the world

* ksud: Fix build on macOS

* manager: bump minimal supported kernel.

- When get_hook_type is empty, display “Unknown”.

* Fix ksud build (#2841)

* try fix ksud

* fix for macos

* remove any

* Fix ksud build, take 3

* try fix allowlist

* bring lsm hook back

* fix: a lot again

* Fix ksud build, take 4 (#2846)

Remove init_driver_fd function for non-linux/android targets

* manager: Return to the native method via KSUd installation

* Merge with susfs-mian format

---------

Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
Co-authored-by: Ylarod <me@ylarod.cn>
Co-authored-by: weishu <twsxtd@gmail.com>
Co-authored-by: AlexLiuDev233 <wzylin11@outlook.com>
Co-authored-by: Wang Han <416810799@qq.com>
2025-11-02 01:11:38 +08:00
ShirkNeko
f2274fab27 Revive SUS_MAP feature
- More details in boot-completed.sh template, ksu_susfs usage and KernelSU Kconfig

Co-authored-by: simonpunk <simonpunk2016@gmail.com>
2025-10-18 14:13:31 +08:00
ShirkNeko
8eeb263bdb kernel & KernelSU: More Optimization on SUS_MOUNT and...
kernel & KernelSU: More Optimization on SUS_MOUNT and AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT; Dropped HAS_MAGIC_MOUNT feature in Kconfig

- In order to stop more performance loss, the changes here is not to monitor any ksu mounts anymore during/after boot-completed stage,
  since monitoring the free of mnt_id and reordering the mnt_id takes some CPU cycles already.

- HAS_MAGIC_MOUNT is not needed anymore and catching magic mounts can be simplifed by checking whether
  1. It is bind mount
  2. Its mnt_devname is "KSU"
  3. It is a directory
  4. mounted path begins with "/debug_ramdisk/workdir/"

- Some sus bind mounts still cannot be catched with these changes, like revanced youtube module,
  since it bind mounts after the user data is decrypted, at this point user may need to manually
  add the mounted path to try_umount.

  Co-authored-by: simonpunk <simonpunk2016@gmail.com>
2025-10-07 16:44:24 +08:00
ShirkNeko
51e6a1b6c7 kernel: Add CONFIG_KSU_MANUAL_SU configuration
- Use random passphrase protection for manual su functionality
2025-09-29 06:50:39 +08:00
ShirkNeko
41f7921993 Revert "kernel: throne_tracker: offload to kthread tiann #2632"
This reverts commit 8364d6d4a4.
2025-09-24 16:26:27 +08:00
ShirkNeko
8364d6d4a4 kernel: throne_tracker: offload to kthread tiann #2632
Run throne_tracker() in kthread instead of blocking the caller.
Prevents full lockup during installation and removing the manager.

By default, first run remains synchronous for compatibility purposes
(FDE, FBEv1, FBEv2)

Features:
- looks and waits for manager UID in /data/system/packages.list
- run track_throne() in a kthread after the first synchronous run
- prevent duplicate thread creation with a single-instance check
- spinlock-on-d_lock based polling adressing possible race conditions.

Race conditions adressed
- single instance kthread lock, smp_mb()
- track_throne_function, packages.list, spinlock-on-d_lock based polling
- is_manager_apk, apk, spinlock-on-d_lock based polling

This is a squash of:
https://github.com/tiann/KernelSU/pull/2632

Original skeleton based on:
`kernelsu: move throne_tracker() to kthread`
`kernelsu: check locking before accessing files and dirs during searching manager`
`kernelsu: look for manager UID in /data/system/packages.list, not /data/system/packages.list.tmp`
0b05e927...8783badd

Co-Authored-By: backslashxx <118538522+backslashxx@users.noreply.github.com>
Co-Authored-By: Yaroslav Zviezda <10716792+acroreiser@users.noreply.github.com>
Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
2025-09-24 01:50:05 +08:00
ShirkNeko
d542fd0672 kernel: Added legacy throne tracker support, using packages.list to scan application UIDs 2025-09-21 17:39:07 +08:00
ShirkNeko
e41fa8ef62 Revert renaming symbols in KernelSU driver
- In order to reduce the extra patch code and increase the rate of hunk succeed, we do not rename the symbols in KernelSU drvier but instead do it all in kernel/kallsym.c

- Make susfs_starts_with() global as it maybe useful in future

Co-authored-by: simonpunk <simonpunk2016@gmail.com>
2025-08-25 19:29:14 +08:00
Prslc
ef399712dc kernel: Introducing Tracepoint Hook Type Support
Tracepoint is a predefined hook point in the kernel, compared to Kprobe,
it is more stable and has lower performance overhead, although compatibility
is relatively poor, it is still worth trying

By the way, we have also included the config definitions related to hook types
in Kconfig, to enhance cleanliness

These patches is based on https://github.com/backslashxx/KernelSU/issues/5

Co-authored-by: Cloud_Yun <1770669041@qq.com>
Co-authored-by: Prslc <prslc113@gmail.com>
2025-08-14 20:59:44 +08:00
ShirkNeko
66ff2fa812 Fix the KSU_SUSFS_HAS_MAGIC_MOUNT dependency to ensure it depends on KSU_SUSFS 2025-07-21 16:29:51 +08:00
ShirkNeko
f5541e215f kernel & KernelSU: Replace kabi member susfs_task_state of tast_struct and use...
kernel & KernelSU: Replace kabi member susfs_task_state of tast_struct and use tast_struct->thread_info.flags instead; Fix for sus_path not working on some OEM devices; KSU_SUSFS requires CONFIG_THREAD_INFO_IN_TASK now;

- Since the kabi member is not guaranteed to be unused by OEM, that is why some deivces may conflict with the kabi member added by susfs, we should use less kabi member as much as possible.
- Luckily we have task_struct->thread_info that is enabled by all gki kernels just like kprobes, so we can utilize thread_info->flags for faster check, but it needs CONFIG_THREAD_INFO_IN_TASK to be on which should always be enabled
- Big thanks to fatalcoder524 (https://github.com/fatalcoder524) who did an excellent debug process for me

Co-authored-by: simonpunk <simonpunk2016@gmail.com>
2025-07-07 13:13:07 +08:00
WenHao2130
5a4a8da820 kernel: Fix typo error
Revise the explanation for KSU_MULTI_MANAGER_SUPPORT

Change-Id: I097b4e0d1a30c02fadd75d4123c7bcf346782f18
Signed-off-by: WenHao2130 <wenhao2130@outlook.com>
2025-07-01 12:47:58 +08:00
YC酱luyancib
4ad011c988 Update Kconfig (#224)
make sure kpm config requrement was enabled
2025-06-30 16:32:09 +08:00
ShirkNeko
8e192aaead kernel: add support for multi KernelSU manager in Kconfig 2025-06-27 00:10:19 +08:00
ShirkNeko
a873411a07 kernel: Bump SuSFS version to v1.5.8 2025-06-13 02:18:29 +08:00
ShirkNeko
1d1a404fa1 Updating the KPM configuration
- We don't know if KPM can run on arm32-bit devices, so to avoid some problems, add a dependency on 64-bit architectures

Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
2025-05-17 18:36:42 +08:00
ShirkNeko
682fdf0afe Prioritize sukisu recognition.
Simplified manual hooks
2025-05-10 14:38:45 +08:00
ShirkNeko
41b8f854a4 Add KSU_CMDLINE configuration to enable the KernelSU command line option and implement the corresponding status read function
Co-authored-by: rsuntk <rsuntk@yukiprjkt.my.id>
Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
2025-04-24 15:03:09 +08:00
ShirkNeko
dfaada7134 Patch update SuSFS version to 1.5.6 2025-04-22 16:20:41 +08:00
ShirkNeko
2c65af9e80 Add a dependency for KPM in Kconfig to ensure that KPM functionality can only be activated when KSU is enabled 2025-04-21 10:42:52 +08:00
ShirkNeko
970e7651a5 Refactoring Kconfig and Makefile to optimize KernelSU configuration logic and simplify kernel type determination 2025-04-19 16:02:18 +08:00
ShirkNeko
bd56bcf538 Refactoring Kconfig to optimize KernelSU-related configuration and simplify conditional dependency logic 2025-04-19 14:02:12 +08:00
ShirkNeko
28f006ed39 Refactor Kconfig and Makefile, update KPROBES related configurations, simplify conditional compilation logic 2025-04-17 19:46:14 +08:00
ShirkNeko
2fc0935f58 更新 KPM 配置,修改为 SukiSU KPM,并添加启用状态信息 2025-03-31 19:40:16 +08:00
ShirkNeko
743ddce9f7 添加 KPM 模块支持,包括 KPM 配置选项、核心功能实现及相关头文件 2025-03-30 02:54:23 +08:00
樱檩殇雪
ad064fea9e add susfs-dev branch files 2025-03-17 02:48:59 +08:00