Commit Graph

431 Commits

Author SHA1 Message Date
ShirkNeko
1b2e7dee97 kernel: Use task work to install fd
There are many fd related functions that can sleep, so we have no choice
but move operations to task work. Also close fd when copy_to_user fails.

Co-authored-by: Wang Han <416810799@qq.com>
2025-11-11 01:13:13 +08:00
ShirkNeko
66f37c7310 Revert "kernel: Apply the SUSFS patch"
This reverts commit ad0f3f6025.
2025-11-09 21:39:04 +08:00
ShirkNeko
3a0f9b4e2c Clean up kernel code (#2898)
1) Fix memory leak of callback head in allowlist.c
2) Remove duplicated logic and incorrect log in kernel_umount.c
3) Prevent sleep in kprobe context in ksud.c
4) Remove useless is_unsupported_uid, use euid for security enhance,
   add FIXME in setuid_hook.c
5) Remove useless fd argument for execve hook, fix incorrent pointer
   usage in syscall_hook_manager.c and sucompat.c
6) Use correct errno in supercalls.c

---------

Co-authored-by: Ylarod <me@ylarod.cn>
2025-11-09 19:23:22 +08:00
ShirkNeko
ad0f3f6025 kernel: Apply the SUSFS patch 2025-11-09 18:32:16 +08:00
ShirkNeko
a2caa9432f fix 2025-11-09 18:10:25 +08:00
ShirkNeko
92e9f4068a kernel: Rollback disable_seccomp
Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
Co-authored-by: Faris <rissu.ntk@gmail.com>
2025-11-09 18:04:49 +08:00
ShirkNeko
ae104ed4a4 kernel: Remove redundant checks 2025-11-09 18:04:32 +08:00
ShirkNeko
1c86944142 kernel: Undo some changes 2025-11-09 16:30:29 +08:00
ShirkNeko
a0ceda008d fix build 2025-11-09 14:14:51 +08:00
ShirkNeko
f670151f20 kernel: Simplify state management logic 2025-11-09 14:06:25 +08:00
ShirkNeko
3e5f69cdf8 kernel: Fix compilation for non-gki kernels
Co-authored-by: TwinbornPlate75 <3342733415@qq.com>
2025-11-09 13:35:42 +08:00
ShirkNeko
a525048d1f kernel: Remove susfs patch 2025-11-09 12:48:51 +08:00
ShirkNeko
c400952b47 clear build 2025-11-09 12:30:52 +08:00
ShirkNeko
f6a0fab2ef Fixes only hook in LKM mode __NR_newfstatat ,__NR_faccessat ,__NR_execve system calls 2025-11-09 12:18:00 +08:00
ShirkNeko
86cd05e206 Attempt to refactor and migrate inode_permission, bprm_check_security, and task_alloc entirely to syscall_hook_manager
kernel: fix build
2025-11-09 04:35:29 +08:00
ShirkNeko
af4b502631 kernel: Rewrite the kernel source code (#554)
* clean unused header

* on_module_mounted in ksud.c

* refact: use app_profile

* unified hook manager

* add zygote to hook target

* move reboot hook to supercall.c

* refactor: kernel_umount setuid_hook

* update mark rules, add init mark tracker

* remove reboot from check_syscall_fastpath

* update setuid_hook, remove uneeded sucompat enable

* log freely

* kernel: Migrate kprobe hook configuration items

* kernel: fix build

* cli: add ksud debug mark

* Fix rustfmt warning

---------

Co-authored-by: Ylarod <me@ylarod.cn>
Co-authored-by: Wang Han <416810799@qq.com>
Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
2025-11-09 03:49:11 +08:00
weishu
678c00cad9 kernel: fix put_task if alloc failed. 2025-11-08 21:44:24 +08:00
AlexLiuDev233
22661c1838 fix: fix 5.0- users can't build (#551)
my mistake, forget old kernel's access_ok has 3 params,
so i switch to ksu_access_ok
2025-11-08 21:33:21 +08:00
ShirkNeko
2f1b967813 kernel: fix build 2025-11-08 20:54:07 +08:00
ShirkNeko
d8db1b6c43 kernel: Resolved compatibility issues with su when using manual hooks 2025-11-08 20:53:37 +08:00
ShirkNeko
3137fc4ee0 kernel: fix build 2025-11-08 20:47:37 +08:00
ShirkNeko
8c849518fb kernel: fix build 2025-11-08 20:45:29 +08:00
ShirkNeko
05179ee119 kernel: Resolve implicit declaration conflicts 2025-11-08 20:29:59 +08:00
Wang Han
bc09a64b1b Fix missing unlock on error path 2025-11-08 20:29:25 +08:00
weishu
8523b380b9 kernel: fix save allowlist 2025-11-08 20:29:12 +08:00
ShirkNeko
e4d7c292d6 kernel: remove unused kernel_compat
Co-authored-by: weishu <twsxtd@gmail.com>
2025-11-08 20:28:58 +08:00
weishu
c307bf5614 kernel: remove ksu_compat_{open,read,write} because we're in the right context now
Co-authored-by: weishu <twsxtd@gmail.com>
2025-11-08 20:22:06 +08:00
ShirkNeko
0b118e19b3 kernel: remove workqueue for allowlist
Co-authored-by: weishu <twsxtd@gmail.com>
2025-11-08 20:18:56 +08:00
ShirkNeko
9c0da2caeb Reworking fdwrapper
Co-authored-by: 5ec1cff <ewtqyqyewtqyqy@gmail.com>
Co-authored-by: 5ec1cff <56485584+5ec1cff@users.noreply.github.com>
Co-authored-by: Ylarod <me@ylarod.cn>
2025-11-08 20:17:37 +08:00
technotic
ba56c81bd0 add include for crc32.h in sulog.h (for dedup_calc_hash) (#548)
Co-authored-by: technotic <pixie@technotic.us>
Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
2025-11-08 18:13:04 +08:00
AlexLiuDev233
30316047d6 refactor: kpm: memory management migrate to sukisu side (#539)
* refactor: kpm: memory management migrate to sukisu side

* fix: build warning in some gki2 device

fix stack frame size warning (maybe) in gki2 device, specialy in ShirkNeko's device

* chore: use pr_info instead of printk

* feat: check the validity of pointers sent from user space
Sometimes, ksud or other root processes might request a kpm ioctl,
but data incorrectly, such as invalid pointer,
which cause the kernel to crash.

If the request is made by ksud at boot time, the situation is even worse,
as it can cause the system to enter the boot loop.

Therefore, I believe we need to check pointer integrity in kernel space to fix this problem.

---------

Co-authored-by: Saksham <typeflu@gmail.com>
Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
2025-11-08 18:10:26 +08:00
TwinbornPlate75
4f7042ca44 kernel: Fix compilation for non-gki kernels (#547)
* kernel: Fix compilation for non-gki kernels

* kernel: Check if selinux_state exists rather than depends on version code
2025-11-08 18:07:09 +08:00
AlexLiuDev233
8ff469d00e kernel: core_hook: disable seccomp in 5.10.2- for allowed uids (#545)
* kernel: core_hook: disable seccomp in 5.10.2- for allowed uids

we dont have those new fancy things upstream has
lets just do original thing where we disable seccomp

* Update kernel/core_hook.c

* fmt

---------

Co-authored-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
Co-authored-by: Saksham <saksham.mac@icloud.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-08 12:50:17 +08:00
ShirkNeko
2e16ba7ac7 cleanup 2025-11-08 12:21:08 +08:00
Ylarod
584fb3b213 fix build 2025-11-08 12:20:33 +08:00
Ylarod
a20c40f580 rename to proxy_file 2025-11-08 12:20:20 +08:00
ShirkNeko
af4d023777 kernel: remove devpts hook 2025-11-08 12:12:58 +08:00
ShirkNeko
90b99615aa Continue add 2025-11-08 01:36:51 +08:00
Wang Han
1ad4a745ad Use force_sig(SIGKILL) to kill process 2025-11-08 01:35:46 +08:00
Shadichy
f39d4f0f38 kernel: Refactor selinux/selinux.c (#2881)
Signed-off-by: shadichy <shadichy@blisslabs.org>
Co-authored-by: Wang Han <416810799@qq.com>
2025-11-08 01:35:37 +08:00
TwinbornPlate75
c24ed3b5c4 kernel: Fix compilation for non-gki kernels (#543) 2025-11-08 01:19:11 +08:00
ShirkNeko
74f24bafed Switch kretprobe to heap
Co-authored-by: Ylarod <me@ylarod.cn>
2025-11-07 19:03:05 +08:00
5ec1cff
c876d60e53 feature: add devpts fd wrapper (#21)
This feature is intended to resolve devpts problem.
2025-11-07 18:49:32 +08:00
ShirkNeko
3662c92854 Compilation fix 2025-11-06 23:39:22 +08:00
Ylarod
6a44e85d2e revert: still using workqueue for allowlist 2025-11-06 23:39:13 +08:00
Ylarod
384d2f7dcd fix: enhanced security register 2025-11-06 23:39:01 +08:00
ShirkNeko
8330bb335a kill pgrp in enhanced security 2025-11-06 23:38:36 +08:00
Ylarod
315fbb464c kill pgrp in enhanced security 2025-11-06 23:38:12 +08:00
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