Commit Graph

385 Commits

Author SHA1 Message Date
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
rifsxd
5e28594e3d kernel: handle throned UID change if manager is reinstall or changed
drop old UID and throne the new one when the manager is reinstalled or changed

- Add dynamic manager lock

Co-authored-by: rifsxd <rifat.44.azad.rifs@gmail.com>
Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
2025-10-06 23:59:32 +08:00
ShirkNeko
8489c442c9 kernel: Rearrange and eliminate potential call delays 2025-10-06 00:08:57 +08:00
ShirkNeko
5779892bbc kernel: Add missing checks 2025-10-05 23:25:08 +08:00
ShirkNeko
c3b8c8601a kernel: Add kernel compatibility for cmd_su 2025-10-05 20:20:46 +08:00
ShirkNeko
12e47663cd kernel: For cmd_su, bypass the susfs_is_current_proc_umounted check only for system processes. 2025-10-05 19:50:17 +08:00
ShirkNeko
0a13055e9b KernelSU: Attempted to fix new prctl side channel detection
- A more aggressive prctl side channel is already implemented by cimb octo app and this is found by backslashxx (https://github.com/backslashxx/)

- The fix is easy same as the one implemented for sus_su by checking the TIF_PROC_UMOUNTED bit in current->thread_info.flags in the very beginning of ksu_handle_prctl()

- Also we need make sure to explicitly check for ksu manager uid in ksu_handle_setuid() before checking for normal user app since ksu maanger app uid is excluded in allow_list_arr which ksu_uid_should_umount(manager_uid) will always return true

Co-authored-by: simonpunk <simonpunk2016@gmail.com>
2025-10-05 18:59:12 +08:00
ShirkNeko
80714f1c4c Revert "kernel: Attemp to fix magic mounts or bind mounts not begin assigned with fake mnt_id"
This reverts commit b00a606adc.
2025-10-05 18:50:44 +08:00
ShirkNeko
b00a606adc kernel: Attemp to fix magic mounts or bind mounts not begin assigned with fake mnt_id
Co-authored-by: simonpunk <simonpunk2016@gmail.com>
2025-10-04 23:29:54 +08:00
ShirkNeko
8650a9ad57 kernel: Fixed disable_seccomp compatibility issues 2025-10-01 00:15:05 +08:00
ShirkNeko
ca67913f05 Brought back the toggle of umount for zygote spawned isolated service; Synced...
Brought back the toggle of umount for zygote spawned isolated service; Synced with KernelSU main branch with latest commit 37ef0d27067d3d7e7bf07a80547a1949864789c4

Co-authored-by: simonpunk <simonpunk2016@gmail.com>
2025-09-30 22:54:19 +08:00
ShirkNeko
9d2ede6aec kernel & KernelSU: Another attempt to optimize SUS_MOUNT and SUS_SU
Changes:

1. Simplified the flow of mnt_id reorder, now it happens only after all sus mounts are umounted in ksu_handle_setuid()

2. All mounts mounted by ksu process will be flagged as sus mount and allocated with a fake mnt_id/mnt_group_id
   during ONLY the post-fs-data and service stage, which means other ksu mounts during/after boot-completed stage
   will not be handled by susfs.

3. Renaming:
   - susfs_mnt_id_ida => susfs_ksu_mnt_id_ida
   - susfs_mnt_group_ida => susfs_ksu_mnt_group_ida
   - DEFAULT_SUS_MNT_ID => DEFAULT_KSU_MNT_ID
   - DEFAULT_SUS_MNT_GROUP_ID => DEFAULT_KSU_MNT_GROUP_ID

4. Increased the default fake mnt_id to 300000, and default fake mnt_group_id to 3000.

5. Unify susfs_is_current_non_root_user_app_proc() and susfs_is_current_proc_su_not_allowed() as susfs_is_current_proc_umounted()
   Unify susfs_set_current_non_root_user_app_proc() and susfs_set_current_proc_su_not_allowed() as susfs_set_current_proc_umounted()
   Unify TIF_NON_ROOT_USER_APP_PROC and TIF_PROC_SU_NOT_ALLOWED as TIF_PROC_UMOUNTED

6. Removed unused susfs_is_allow_su()

7. Reworked a custom ksu_handle_setuid() which will be used if CONFIG_KSU_SUSFS is defined

Co-authored-by: simonpunk <simonpunk2016@gmail.com>
2025-09-30 22:50:48 +08:00
ShirkNeko
51e6a1b6c7 kernel: Add CONFIG_KSU_MANUAL_SU configuration
- Use random passphrase protection for manual su functionality
2025-09-29 06:50:39 +08:00
ShirkNeko
1281fa70d7 Kernel: Enhanced temporary record UID functionality and elevated privileges 2025-09-29 04:28:31 +08:00
ShirkNeko
3a4775306e Revert "kernel: sucompat: increase reliability, commonize and micro-optimize tiann #2656"
This reverts commit dd1eb98963.
2025-09-28 19:36:36 +08:00
ShirkNeko
7c4334e03a kernel: Add the ability to manually elevate privileges for programs using prctl by specifying UID or PID. 2025-09-28 19:33:08 +08:00
ShirkNeko
3f0f34e5b1 kernel: core_hook: add support for KernelNoSU ([#270](https://github.com/SukiSU-Ultra/SukiSU-Ultra/issues/270))
reorder ksu_handle_prctl checks a bit to allow non-manager to use CMD 15
this allows us to piggyback a small su to KernelSU's permission system after
disabling kernel sucompat

from:
Relax prctl perm check
- 95125c32f9
Allow prctl only for root or manager or su binary
- fa7af67d94
Refine prctl access check, allow /product/bin/su
- dd466dc1b6
Refine prctl check a little bit more
- e7c5b24efa

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
Co-authored-by: nampud <nampud@users.noreply.github.com>
2025-09-27 23:59:21 +08:00
ShirkNeko
3140d9671f kernel: Revert partial changes 2025-09-27 22:45:23 +08:00
ShirkNeko
3a8b5561ec kernel: fmt ,optimization Log 2025-09-27 21:07:01 +08:00