Commit Graph

16 Commits

Author SHA1 Message Date
ShirkNeko
329b7f59dc KernelSU: SUS_SU: Initiate path with 0 and no memset is needed
1. kernel & KernelSU: More optimization for SUS_SU mode 2 (Experimental)

2. Always flag zygote spawned isolated service as non-root user app process and no su allowed process

3. Change susfs_fake_qstr_name, shorter length

4. KernelSU: SUS_SU: Initiate path with 0 and no memset is needed

Co-authored-by: simonpunk <simonpunk2016@gmail.com>
2025-07-15 10:24:43 +08:00
rsuntk
bb02b12a69 kernel: phase out devpts_hook
* Since it's interceptable from LSM Hook,
then we just need to remove ksu_handle_devpts and
make a decoy for it.

Signed-off-by: rsuntk <rsuntk@yukiprjkt.my.id>
2025-06-27 12:31:38 +08:00
rsuntk
103217755b kernel: allow GKI kprobes to use LSM hook for ksu_handle_devpts
* Also minor changes on comments

Signed-off-by: rsuntk <rsuntk@yukiprjkt.my.id>
2025-06-20 00:30:15 +08:00
ShirkNeko
a873411a07 kernel: Bump SuSFS version to v1.5.8 2025-06-13 02:18:29 +08:00
ShirkNeko
17905c71b6 kernel: sucompat: improve error handling and add conditional hooks 2025-06-12 16:55:20 +08:00
ShirkNeko
87b57d9eba kernel: Update sucompat.c to improve hook state management and code clarity
Co-authored-by: rsuntk <90097027+rsuntk@users.noreply.github.com>
2025-06-12 15:53:17 +08:00
backslashxx
5aed2c2d2d kernel: sucompat: increase reliability of execve_sucompat
On plain ARMv8.0 devices (A53,A57,A73), strncpy_from_user_nofault() sometimes
fails to copy `filename_user` string correctly. This breaks su ofc, breaking
some apps like Termux (Play Store ver), ZArchiver and Root Explorer.

This does NOT seem to affect newer ARMv8.2+ CPUs (A75/A76 and newer)

My speculation? ARMv8.0 has weak speculation :)

here we replace `strncpy_from_user_nofault()` with another routine:
 - access_ok() to validate the pointer
 - strncpy_from_user() to copy and validate string
 - manual null-termination just in case, as strncpy_from_user_nofault also does it
 - remove that memset, seems useless as it is an strncpy, not strncat

Kind of mimicking _nofault, but yes with this one we allow pagefaults.

Tested on:
- ARMv8.0 A73.a53, A57.a53, A53.a53
- ARMv8.2 A76.a55

Tested-by: iDead XD <rafifirdaus12bb@gmail.com>
Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
2025-05-24 14:37:51 +08:00
ShirkNeko
95c47b8602 Fixed misspelling of CONFIG_KSU_HOOK_KPROBES to CONFIG_KSU_KPROBES_HOOK in Makefile and related files. 2025-05-17 18:33:29 +08:00
ShirkNeko
a5d6978b32 kernel: sucompat: sucompat toggle support for non-kp (tiann#2506)
This is done like how vfs_read_hook, input_hook and execve_hook is disabled.
While this is not exactly the same thing, this CAN achieve the same results.
The complete disabling of all KernelSU hooks.

While this is likely unneeded, It keeps feature parity to non-kprobe builds.

adapted from upstream:
	kernel: Allow to re-enable sucompat - tiann/KernelSU@4593ae8

Rejected: tiann/KernelSU#2506

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
2025-05-17 18:30:19 +08:00
backslashxx
e3b6f4d35d kernel: sucompat: sucompat toggle support for non-kp (tiann#2506)
kernel/selinux: fix pointer mismatch with 32-bit ksud on 64-bit kernels
Since KernelSU Manager can now be built for 32-bit, theres this problematic
setup where userspace is 32-bit (armeabi-v7a) and kernel is 64bit (aarch64).

On 64-bit kernels with CONFIG_COMPAT=y, 32-bit userspace passes 32-bit pointers.
These values are interpreted as 64-bit pointers without proper casting and that
results in invalid or near-null memory access.

This patch adds proper compat-mode handling with the ff changes:
- introduce a dedicated struct (`sepol_compat_data`) using u32 fields
- use `compat_ptr()` to safely convert 32-bit user pointers to kernel pointers
- adding a runtime `ksu_is_compat` flag to dynamically select between struct layouts

This prevents a near-null pointer dereference when handling SELinux
policy updates from 32-bit ksud in a 64-bit kernel.

Truth table:

kernel 32 + ksud 32, struct is u32, no compat_ptr
kernel 64 + ksud 32, struct is u32, yes compat_ptr
kernel 64 + ksud 64, struct is u64, no compat_ptr

Preprocessor check

64BIT=y COMPAT=y: define both structs, select dynamically
64BIT=y COMPAT=n: struct u64
64BIT=n: struct u32

kernel/throne_tracker: we just uninstalled the manager, stop looking for it
When the manager UID disappears from packages.list, we correctly
invalidate it — good. But, in the very next breath, we start scanning
/data/app hoping to find it again?

This event is just unnecessary I/O, exactly when we should be doing less.
Apparently this causes hangups and stuckups which is REALLY noticeable
on Ultra-Legacy devices.

Skip the scan — we’ll catch the reinstall next time packages.list updates.

This is done like how vfs_read_hook, input_hook and execve_hook is disabled.
While this is not exactly the same thing, this CAN achieve the same results.
The complete disabling of all KernelSU hooks.

While this is likely unneeded, It keeps feature parity to non-kprobe builds.

adapted from upstream:
	kernel: Allow to re-enable sucompat - 4593ae81c7

Rejected: https://github.com/tiann/KernelSU/pull/2506

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
2025-05-15 20:23:18 +08:00
ShirkNeko
069a671bf1 Remove unnecessary conditional compilation code to simplify the definition of kprobe structures 2025-04-23 17:26:00 +08:00
ShirkNeko
13c5aae85e Move variable declarations in the for loop outside the loop in sucompat.c 2025-04-23 17:16:10 +08:00
ShirkNeko
527d362b85 Add support for Kprobe, extend su_kps array to 6 elements to accommodate more hook functions 2025-04-23 15:08:05 +08:00
ShirkNeko
dfaada7134 Patch update SuSFS version to 1.5.6 2025-04-22 16:20:41 +08:00
ShirkNeko
28f006ed39 Refactor Kconfig and Makefile, update KPROBES related configurations, simplify conditional compilation logic 2025-04-17 19:46:14 +08:00
樱檩殇雪
ad064fea9e add susfs-dev branch files 2025-03-17 02:48:59 +08:00