Commit Graph

481 Commits

Author SHA1 Message Date
Ylarod
bcf2a7632c add mutex for sucompat mark 2025-11-06 23:37:56 +08:00
ShirkNeko
d416a0add7 fix: sucompat (#2874)
Co-authored-by: Ylarod <me@ylarod.cn>
2025-11-06 23:37:05 +08:00
ShirkNeko
c1ecb8f3b9 kernel: clean code 2025-11-06 15:24:33 +08:00
ShirkNeko
e8ecb9a33b kernel: Resolving compilation issues once more 2025-11-06 15:18:39 +08:00
ShirkNeko
3382574aad kernel: Resolve compilation issues 2025-11-06 14:50:46 +08:00
ShirkNeko
54e1e3dda3 kernel: clean headers
Co-authored-by: weishu <twsxtd@gmail.com>
2025-11-06 14:46:24 +08:00
ShirkNeko
5a1ff92d0a fix 2025-11-06 14:45:42 +08:00
weishu
a30b932969 kernel: Set the tracepoint flag in a tracepoint manner 2025-11-06 14:44:32 +08:00
Ylarod
752ec03694 feature: add enhanced security (#2873) 2025-11-06 14:44:20 +08:00
weishu
64045b5386 kernel: remove unused workqueue 2025-11-06 14:41:39 +08:00
Ylarod
a81da2c586 fix sepolicy patch hint (#2872) 2025-11-06 14:39:54 +08:00
Ylarod
dcbc014039 fix: mark tif (#2871) 2025-11-06 14:37:47 +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
ee9c20f62a kernel: Migrate manual_su to ioctl 2025-11-06 03:01:31 +08:00
ShirkNeko
77fbfb7796 kernel: Resolved permission verification issue 2025-11-05 19:08:01 +08:00
ShirkNeko
3a8e114201 kernel: Fix compilation 2025-11-05 17:15:18 +08:00
ShirkNeko
1473b91901 Use a more appropriate minor version number 2025-11-05 16:45:07 +08:00
ShirkNeko
5b6c82db32 fix 2025-11-05 16:18:59 +08:00
ShirkNeko
419299a1ad bump KSU_VERSION_API to 4.0.0 2025-11-05 16:11:14 +08:00
backslashxx
9f06c5f15d kernel: supercall: allow escalation on ioctl interface (#2862)
Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
2025-11-05 16:03:56 +08:00
ShirkNeko
453a785e97 v2.0 2025-11-05 16:03:34 +08:00
ShirkNeko
f9f75d73d8 Kernel: Enable processes with corresponding UIDs to utilise netlink, and optimise netlink functionality 2025-11-05 16:02:40 +08:00
ShirkNeko
766b6d2c76 kernel: Remove prctl; use netlink communication to control manual_su 2025-11-05 15:57:18 +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
1e0590aeb2 fix 2025-11-04 22:38:13 +08:00
weishu
b8df3163c1 kernel: init/exit umount feature 2025-11-04 22:30:16 +08:00
ShirkNeko
1a70506f0e kernel: rework umount with task_work
Co-authored-by: weishu <twsxtd@gmail.com>
2025-11-04 22:24:00 +08:00
ShirkNeko
fa229b23a4 kernel: Remove CONFIG_KSU_MANUAL_SU protection 2025-11-04 21:48:06 +08:00
backslashxx
aef96cd93c kernel: core_hook: provide a better reboot handler (#523)
* Revert "feat: try manual reboot hook (#521)"

This reverts commit 1853d9decf.

* kernel: core_hook: provide a better reboot handler

I propose that you pass cmd and arg as reference.
this is so we can have much more extendable use of that pointer

kernel: core_hook: provide sys_reboot handler
- 2e2727d56c

kernel: kp_ksud: add sys_reboot kp hook
- 03285886b0

I'm proposing passing arg as reference to arg pointer and also pass int cmd
we can use it to pass numbers atleast.
for advanced usage, we can use it as a delimiter so we can pass a pointer to array.

example pass a char *array[] which decays to a char ** and then use cmd as the number of array members.
we can pass the pointer of the first member of the array and use cmd as the delimiter (count) of members.

for simpler usecase, heres some that I added.

kernel: core_hook: expose  umount list on sys_reboot interface
- 352de41e4b

kernel: core_hook: expose nuke_ext4_sysfs to sys_reboot interface
- 83fc684ccb

ksud: add cmd for add-try-umount, wipe-umount-list and nuke-ext4-sysfs
- a4eab4b8c3

more usage demos
https://github.com/backslashxx/lkm_template/tree/write-pointer-on-pointer
https://github.com/backslashxx/lkm_template/tree/pointer-reuse

I actually proposed sys_reboot upstream because of this pointer that is very usable.

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>

---------

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
2025-11-04 20:15:01 +08:00
ShirkNeko
d6c6899d28 Continue fix 2025-11-04 11:21:52 +08:00
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