Commit Graph

2273 Commits

Author SHA1 Message Date
F-19-F
1d1e0f1e7f kernel: provide is_ksu_transition check
context: this is known by many as `selinux hook`, `4.9 hook`

add is_ksu_transition check which allows ksud execution under nosuid.
it also eases up integration on 3.X kernels that does not have check_nnp_nosuid.

this also adds a `ksu_execveat_hook` check since this transition is NOT needed
anymore once ksud ran.

Usage:
	if (check_ksu_transition(old_tsec, new_tsec))
		return 0;

on either check_nnp_nosuid or selinux_bprm_set_creds (after execve sid reset)

reference: dfe003c9fd

taken from:
`allow init exec ksud under nosuid`
- 3df9df42a6
- https://github.com/tiann/KernelSU/pull/166#issue-1565872173

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
Signed-off-by: rsuntk <rsuntk@yukiprjkt.my.id>
2025-06-11 14:44:06 +08:00
ShirkNeko
aec76a388f kernel: add package whitelist check for manager APKs
Co-authored-by: lamadaemon <i@lama.icu>
Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
2025-06-07 00:48:06 +08:00
rsuntk
3b8445cdaa kernel: Remove more stray backslash in grep regex and move path_umount as optional backport 2025-06-07 00:35:23 +08:00
Tashfin Shakeer Rhythm
6225985f6f kernel: Makefile: Remove stray backslash from path_umount grep regex (#103)
Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
2025-06-07 00:35:14 +08:00
Paul
d52fc57fc4 kernel: core_hook: intercept devpts via security_inode_permission LSM (#137)
`ksu handles devpts with selinux lsm hook` - aviraxp

- no, not yet, but yes we can, thats a good idea.

This change tries to do that, so instead of hooking pts_unix98_lookup or
devpts_get_priv, we just watch security_inode_permission, if its devpts,
pass it along to the original handler.

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
Co-authored-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
2025-06-04 20:24:10 +08:00
5ec1cff
79c298cae1 throne_tracker: avoid cross fs access 2025-06-03 00:03:44 +08:00
ShirkNeko
ab3aa84173 kernel: remove SELinux Makefile and add manager to .gitignore 2025-05-28 14:18:08 +08:00
ShirkNeko
b337fc869c kernel: remove unused ksu_task_prctl function 2025-05-27 15:34:19 +08:00
ShirkNeko
08d0b2b048 kernel: include KPM header in core_hook.c 2025-05-27 15:13:32 +08:00
ShirkNeko
622c681ffc kernel: update comments and picked some from upstream
Signed-off-by: rsuntk <90097027+rsuntk@users.noreply.github.com>
2025-05-27 15:12:32 +08:00
rsuntk
98d25694dc kernel: make path_umount backporting as optional
Since https://github.com/backslashxx/KernelSU/commit/4f8943a, path_umount is no longer needed.

Signed-off-by: rsuntk <rsuntk@yukiprjkt.my.id>
2025-05-24 14:33:05 +08:00
ShirkNeko
d9f54a8e42 Refactoring KPM support to check KPM status using CMD_ENABLE_KPM 2025-05-24 14:32:46 +08:00
backslashxx
a3a847a885 kernel: core_hook: screw path_umount backport, call sys_umount directly
I am repasting here what I posted on the source code originally:

/*
 * turns out path_umount backport is completely unneeded
 * we copy the trick used on strncpy_from_unsafe_user / strncpy_from_user_nofault
 * https://elixir.bootlin.com/linux/v4.4.302/source/mm/maccess.c#L184
 * basically
 *
 *     mm_segment_t old_fs = get_fs();     // remember original fs segment
 *     set_fs(USER_DS);                    // or KERNEL_DS *
 *     do_whatever_in_userspace();
 *     set_fs(old_fs);                     // restore fs segment
 *
 *  * kernel -> user, KERNEL_DS, user -> kernel, USER_DS
 *
 * so yes, we can try to straight up call a syscall from kernel space
 *
 * NOTE: on newer kernels you can use force_uaccess_begin + force_uaccess_end
 * ref: https://elixir.bootlin.com/linux/v5.10.237/source/mm/maccess.c#L250
 *
 */

path_umount backport now optional — neat trick, werks, what can I say.

Backports? Nah, we’re good.

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
2025-05-24 14:27:00 +08:00
backslashxx
bf06b92850 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:26:31 +08:00
ShirkNeko
80e3c736d1 kernel: fix repository URL for KernelSU cloning 2025-05-20 12:53:05 +08:00
ShirkNeko
a16f150269 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

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?

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

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
2025-05-17 18:45:01 +08:00
backslashxx
8d066b9ec5 kernel: expose KSU_LSM_SECURITY_HOOKS on Kconfig (#77)
disabling this removes the need for LSM_HOOK_INIT, security_add_hooks and such,.
furthermore, this will also allow easier integration on pre-4.1 kernels.
Expose this and make it a configurable option.

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
2025-05-15 20:28:44 +08:00
sidex15
db547eecf1 kernel: kpm: add compatibility for kernel 4.14 and lower (#76)
`thread_pid` is not defined in kernel 4.14 and lower, leading to compilation issue.
To fix this, use `pids[PIDTYPE_PID].pid` for kernel versions 4.14 and lower.
Else use `thread_pid` for kernel versions 4.19 and higher.

Reference: 107717913b/tracee/tracee.bpf.c (L354)
2025-05-15 17:38:34 +08:00
ShirkNeko
0973cd1ae0 kernel: handle samsung selinux driver
* Some samsung kernel source have SEC_SELINUX_PORTING_COMMON
* This commit mayfix false warning to sepolicy.

Mayfix: I haven't test it yet

Signed-off-by: rsuntk <90097027+rsuntk@users.noreply.github.com>
2025-05-12 19:29:25 +08:00
ShirkNeko
8c6f50815a Clean up the project structure and keep only the kernel 2025-05-12 19:26:18 +08:00
ShirkNeko
c98cf121dc Optimized SELinux compatibility support, adapted data structures to support 32-bit and 64-bit kernels
Co-authored-by: rsuntk <rsuntk@yukiprjkt.my.id>
Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
2025-05-12 19:24:40 +08:00
ShirkNeko
037c5b6c73 kernel: rename KernelSU to SukiSU and update versioning logic 2025-05-10 14:12:48 +08:00
ShirkNeko
9d920e7cc5 kernel: added compatibility for non-GKI devices
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-05-10 13:19:30 +08:00
ShirkNeko
59e3675a36 {docs}:Fixed description of KPROBES and manual hooks, simplified content 2025-05-10 12:17:00 +08:00
米凛MiRin
bc386f080d 修正 README 中错误和误导性内容。 (#71)
* 修正文档

* Update README-en.md

* Update README-ja.md
2025-05-09 22:27:53 +08:00
ShirkNeko
2dc1377154 Update Android Gradle plugin version to 8.10.0 2025-05-09 19:14:46 +08:00
WenHao2130
610852e2f2 [skip ci]: manager: modify background image control logic (#70)
* manager: modify background image control logic

Signed-off-by: WenHao2130 <WenHao2130@outlook.com>

* manager: modify padding

Signed-off-by: WenHao2130 <WenHao2130@outlook.com>

* docs: update README.md README-en.md README-ja.md

Signed-off-by: WenHao2130 <WenHao2130@outlook.com>

---------

Signed-off-by: WenHao2130 <WenHao2130@outlook.com>
2025-05-09 16:58:01 +08:00
ShirkNeko
15b19bb8ce Remove unnecessary card color calculations and simplify theme colors 2025-05-08 11:58:28 +08:00
ShirkNeko
4a598b1837 [skip ci]: Correction of translation errors 2025-05-07 11:30:01 +08:00
ShirkNeko
caee2417d6 [skip ci]:
Fixing tools used by kernels under 5.10
-Add Slot selection is not displayed for non-ab partitions
2025-05-05 22:09:01 +08:00
ShirkNeko
349ca36d4e [skip ci]: Remove unnecessary center point calculation code to simplify bitmap transformation logic 2025-05-05 21:09:31 +08:00
ShirkNeko
ec86f5caf2 [skip ci]:Simplifying Conditional Judgment in the Selection of Installation Methods 2025-05-05 21:09:31 +08:00
ShirkNeko
b5a5cdfcd2 [skip ci]: Fixed “Kernel Module” to “KPM” in string resources. 2025-05-05 21:09:31 +08:00
YC酱luyancib
72d799e065 [skip]: manager: adjust translate on zh-rCN 2025-05-05 21:09:30 +08:00
ShirkNeko
d06f22dcd0 manager: continue to improve the UI
- Expose anykernel3 flashing as long as there is root.
- Opt some styles
2025-05-05 21:09:30 +08:00
ShirkNeko
cb90630f27 Optimize the interface, add hidden link card function, adjust scrolling behavior, clean up unnecessary code 2025-05-05 21:09:30 +08:00
Re*Index. (ot_inc)
59ad9204d0 Update Japanese translated (#64) 2025-05-05 21:09:30 +08:00
ShirkNeko
cb97c16f5e Fix LKM build error due to kernel module listing
Co-authored-by: James McConnell <bins4us@hotmail.com>
Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
Co-authored-by: Rifat Azad <33044977+rifsxd@users.noreply.github.com>
Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
2025-05-05 21:04:25 +08:00
ShirkNeko
69b48d5345 Comment out the cleanup command to avoid accidentally deleting protected exports. 2025-04-30 20:27:54 +08:00
ShirkNeko
45ed4708c9 Optimize the HomeScreen component, refactor the device model acquisition logic, add anti-shake scrolling processing, clean up unused imports 2025-04-30 20:01:39 +08:00
ShirkNeko
f3c77bdb3b [skip ci]: Remove unused animation imports to optimize code cleanliness 2025-04-30 19:49:59 +08:00
ShirkNeko
dc0eb9eec1 Fix duplicate creation of popup windows 2025-04-30 19:48:40 +08:00
ShirkNeko
83dd6443cb Optimize KpmScreen interface layout, adjust button and text display, update signature configuration code 2025-04-30 02:49:09 +08:00
ShirkNeko
3d77f2d135 Adjust the spacing and size of interface elements to optimize the layout effect 2025-04-29 21:46:38 +08:00
ShirkNeko
1ea219bddc Updated GKI installation selection style 2025-04-29 18:07:29 +08:00
ShirkNeko
39adba62d1 Update the default theme color to blue and remove the related blue theme code 2025-04-29 17:29:45 +08:00
ShirkNeko
3526e84e04 Refactor the UI to rewrite the interface (#61) 2025-04-29 15:52:56 +08:00
ShirkNeko
bfdb706b60 Add kernel version and patch tool version log information
- Should fix the 5.10 bug where you can't swipe write

Signed-off-by: ShirkNeko 109797057+ShirkNeko@users.noreply.github.com
2025-04-28 16:05:59 +08:00
ShirkNeko
a297e07055 Adjust the prompt for file selection and add instructions for mirror repair.
- Modify the maximum height of the progress bar to improve user experience
- Add localized strings for error messages and installation methods.
-Optimize the installation interface

Signed-off-by: ShirkNeko 109797057+ShirkNeko@users.noreply.github.com
2025-04-28 14:39:09 +08:00
ShirkNeko
56b4664ec7 Optimized the UI of the slot selection dialog box, added separator lines and button styles, and improved the display logic of the current slot. v3.0.1 2025-04-27 22:37:56 +08:00