Commit Graph

351 Commits

Author SHA1 Message Date
backslashxx
23083ccb9c Reapply: "kernel: Allow to use in Private Space" (#2857)
rebase of
0576495b4b

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
Co-authored-by: weishu <twsxtd@gmail.com>
2025-11-04 11:20:59 +08:00
AlexLiuDev233
e6518a654f feat: try manual reboot hook (#521)
* feat: try manual reboot hook

* refactor: move ksu_handle_reboot to supercalls.c for ShirkNeko

---------
2025-11-04 01:13:16 +08:00
ShirkNeko
2075d2867e kernel: Migrating KPM to ioctl 2025-11-04 00:54:38 +08:00
ShirkNeko
1e122b2469 fix 2025-11-03 12:56:10 +08:00
ShirkNeko
696a2a5dc3 kernel: remove dynamic alloc in feature
Co-authored-by: Ylarod <me@ylarod.cn>
2025-11-03 12:39:20 +08:00
ShirkNeko
6b62e897ce fix lot (#518)
* refact: use feature subsystem

* use 64bit feature

* fix

* add fixme

* add feature max to get_info

* use 32bit feature id

* allow root to get/set feature

* more clean perm_check functions

* fix

* add feature command to ksud

kernel: do not expose perm checker

* fix security_task_fix_setuid_handler_pre

* add android16-6.12 ci

* manager: add kernel_umount switch

Co-authored-by: YuKongA <70465933+YuKongA@users.noreply.github.com>

* manager: Reinstate the LKM selection function

* kernel: add name and print command value

- Optimise sulog log display

Co-authored-by: Ylarod <me@ylarod.cn>
Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>

* fix

* ksud: clippy

---------

Co-authored-by: Ylarod <me@ylarod.cn>
Co-authored-by: YuKongA <70465933+YuKongA@users.noreply.github.com>
Co-authored-by: weishu <twsxtd@gmail.com>
2025-11-03 00:07:36 +08:00
Ylarod
589ac304d3 switch ns umount 2025-11-02 23:58:09 +08:00
Wang Han
2dfc802d90 Implement workqueue for unmounting
umount schedules, so it cannot be used in kprobe context.
2025-11-02 23:56:18 +08:00
TwinbornPlate75
9db87ae630 kernel: Fix compilation (#520)
The definiton of fsnotify_add_mark changed multiple times, once in 4.11-rc2, once in 6.9-rc1, so older kernels still need to fix.
2025-11-02 21:30:12 +08:00
TwinbornPlate75
f87066473b Fix a few incompatibility issues (#517)
* kernel: Use NR_syscalls instead of SECCOMP_ARCH_NATIVE_NR
Old kernels don't has SECCOMP_ARCH_NATIVE_NR. But according to its definition,
it's equal to NR_syscalls. So use NR_syscalls instead.

* kernel: Fix wrong kernel version check
fsnotify_add_inode_mark was introduced in 4.17-rc5, not 4.12
2025-11-02 19:59:29 +08:00
Faris
7f2c838145 kernel: tidy-up code
Signed-off-by: Faris <rissu.ntk@gmail.com>
2025-11-02 14:15:23 +08:00
ShirkNeko
b3fab49730 kernel: Fixing the compilation error when enabling sus_su 2025-11-02 12:35:11 +08:00
ShirkNeko
3b4647cc81 kernel: Add sulog records for supercalls 2025-11-02 02:20:06 +08:00
ShirkNeko
97fb509b50 kernel: fix compilation 2025-11-02 01:36:36 +08:00
Faris
0375058d41 kernel: pkg_observer: fix pre-4.12 kernel compilation issue (#182)
* Linux 4.12+
void fsnotify_init_mark(struct fsnotify_mark *mark,
			struct fsnotify_group *group)

* Linux <4.12
void fsnotify_init_mark(struct fsnotify_mark *mark,
			void (*free_mark)(struct fsnotify_mark *mark))

Tested-by: koyufox <koyufox@gmail.com>
Signed-off-by: Faris <rissu.ntk@gmail.com>
2025-11-02 01:21:47 +08:00
Faris
7145fd537d kernel: replace fsnotify_add_mark_locked to fsnotify_add_inode_mark for pre Linux-4.12
* oof, this function is correct already

Signed-off-by: Faris <rissu.ntk@gmail.com>
2025-11-02 01:19:40 +08:00
Faris
e0aafc66c6 kernel: pkg_observer: Add (half) older kernel compatibility support (#181)
* Pre Linux 5.9, handle_inode_event did not exist. This is was covered by handle_event.
* handle_event have a lot of changes, neither in arguments counts and arguments arrangements.
* Use fsnotify_add_mark_locked instead of fsnotify_add_inode_mark for kernel pre 4.12

NOTE: fsnotify_add_mark_locked is not tested! Report bugs if you found it!

Signed-off-by: Faris <rissu.ntk@gmail.com>
2025-11-02 01:19:30 +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
d7b55bf8b1 Compilation fixed; defaults to fallback using packages.list 2025-11-02 00:33:44 +08:00
ShirkNeko
4aa73f2869 kernel: Fix time64_to_tm scope 2025-11-01 15:19:10 +08:00
MorStar
3933de0ae9 Fix compilation errors on the newer kernels (#509)
* Fix compilation errors on the newer kernels

* 更新 Makefile

* 更新 Kconfig

* 更新 sulog.c
2025-11-01 14:47:30 +08:00
MorStar
4b1bbda3b1 add rtc_time compatibility for older kernels (#504)
* KernelSU: add rtc_time compatibility for older kernels

* KernelSU: add rtc_time compatibility for older kernels
2025-10-31 21:55:04 +08:00
ShirkNeko
343c6452cf 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>
2025-10-27 21:54:20 +08:00
ShirkNeko
3701d47fbb kernel: Simplified manual SU command processing for code 2025-10-27 15:14:35 +08:00
TwinbornPlate75
7a769775d8 kernel/manual_su: Define mmap_lock as mmap_sem for old kernel (#495) 2025-10-27 00:12:44 +08:00
ShirkNeko
979685feaf kernel: Greenlight the new prctl command 2025-10-26 20:43:29 +08:00
ShirkNeko
1b0f96cc70 kernel: Add functionality to generate and validate authentication tokens for cmd_su 2025-10-26 19:59:57 +08:00
ShirkNeko
1ea6af52a0 kernel: Enable macro protection for sulog
- Only enabled on kernel versions greater than 5.10.245
2025-10-25 00:48:02 +08:00
ShirkNeko
163424673f kernel: sulog: Simplify code using vfs_truncate 2025-10-23 22:15:44 +08:00
JackAltman
0cf65d71b6 sus_su: more precise control of the SUS_SU functionality. (#490)
* kernel: Restore the sequence of sulog logs

* sus_su: more precise control of the SUS_SU functionality.

For devices with kernels from 4.9 to 4.14, the SUS_SU functionality
cannot be used due to serious defects in Kprobes. Therefore, the
corresponding SuSFS lacks all code related to the SUS_SU definitions.

---------

Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
2025-10-23 21:50:54 +08:00
ShirkNeko
923153db70 kernel: Replace workqueue creation with alloc_workqueue for improved performance 2025-10-23 21:40:17 +08:00
ShirkNeko
31fb74616d kernel: Restore the sequence of sulog logs 2025-10-23 21:07:38 +08:00
ShirkNeko
0d55990b98 kernel: Add a UID blacklist feature to restrict the operational permissions of specific users 2025-10-23 01:49:35 +08:00
ShirkNeko
12f1f44b11 kernel: Adjust the command processing sequence 2025-10-22 23:56:16 +08:00
ShirkNeko
1a63b2d756 kernel: Extend sulog to also record system call logs 2025-10-22 20:43:14 +08:00
ShirkNeko
ad3cd241f8 kermel: Optimize timestamp retrieval logic by replacing startup time with actual time. 2025-10-22 18:18:02 +08:00
ShirkNeko
b8e463b532 Kernel: Implement sulog for enhanced logging of SU attempts and permissions 2025-10-22 17:21:58 +08:00
ShirkNeko
c4a60378a0 Kernel(Makefile): Add KSU_SRC to set path correctly #483
try Fix version define for 6.12 Kernel

Co-authored-by: YC酱luyancib <luyancib@qq.com>
2025-10-21 16:38:35 +08:00
Sultan Alsawaf
d9be01661a kernel: Fix kernel panics caused by thread info flag corruption
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
2025-10-21 16:37:00 +08:00
ShirkNeko
8b90ab778f KernelSU: Some optimization on parsing susfs CMD; Synced with latest commit of...
KernelSU: Some optimization on parsing susfs CMD; Synced with latest commit of official KernelSU: 0390ef5dd73252115e486d3301f9b3234ebf46aa

- Removed redundant ksu_access_ok() check since copy_to_user has dealt with it already on kernel version >= 5.10

- move int error = 0; before the parse of susfs CMD so that we do not need to declare it again and again in each arg2 compare block

- Synced with upstream, see 0390ef5dd7

Co-authored-by: simonpunk <simonpunk2016@gmail.com>
2025-10-21 16:36:15 +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
761b5ee687 kernel: Optimize prctl filtering 2025-10-15 04:46:13 +08:00
ShirkNeko
37300fefd4 kernel: Remove susfs status retrieval 2025-10-13 15:37:35 +08:00
ShirkNeko
96d0b96fe8 Kernel: Add support for 6.12
Filtered from tiann/KernelSU #2793

Co-authored-by: libingxuan <84086386+aaaaaaaa-815@users.noreply.github.com>
2025-10-08 15:00:32 +08:00
ShirkNeko
ffc1f13fbc kernel: Simplified Logic 2025-10-08 14:49:11 +08:00
unknow-tech
122ae30395 Add support for 6.13 (#454)
Fiz issue https://github.com/SukiSU-Ultra/SukiSU-Ultra/issues/364

cdd30ebb1b
2025-10-08 14:49:05 +08:00
rsuntk
bf408f7965 kernel: add guard for avoiding LKM being builded on Linux 6.8+
* Due to numerous changes on LSM (Linux Security Module) in Linux 6.8+
* This is temporary guard until a working solution exist.

Signed-off-by: rsuntk <rsuntk@yukiprjkt.my.id>
2025-10-07 16:52:54 +08:00
Huy Minh
44834f0172 kernel: add initial 6.8+/6.14 kernel support
* This is a squashed of un-merged pull requests of Official KernelSU
* LKM support are not available.
* Require this additional patch to avoid kernel panic because of "Too many LSMs registered":
7042991a5c

* Un-merged pull requests of Official KernelSU:
https://github.com/tiann/KernelSU/pull/1785
https://github.com/tiann/KernelSU/pull/2662

* This commit probably not 100% completed.

Signed-off-by: rsuntk <rsuntk@yukiprjkt.my.id>
2025-10-07 16:52:42 +08:00
rsuntk
ad0fb7d89f kernel: make apk_sign_key as a typedef instead
Style preference.

Signed-off-by: rsuntk <rsuntk@yukiprjkt.my.id>
2025-10-07 16:52:35 +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