Commit Graph

109 Commits

Author SHA1 Message Date
nampud
948975ba35 kernel: core_hook: add support for KernelNoSU
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>
2025-07-21 06:19:34 +06:00
Rifat Azad
bd03c296a1 kernel/Makefile: remove redundant get_cred_rcu backports 2025-07-14 20:11:13 +06:00
Rifat Azad
b567e9b275 kernel: add better error message if CMD_GET_MANAGWR_UID fails to fetch manager_uid 2025-07-11 04:11:17 +06:00
Rifat Azad
4e3f06d405 kernel: added new prctl CMD_GET_MANAGER_UID to get the uid of the crowned manager
manager: show crowned manager uid in infocard when developer options is enabled
2025-06-30 14:22:19 +06:00
rsuntk
d6601e1e54 kernel: core_hook: fix refcount leaks on try_umount (#2635)
Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
Signed-off-by: rsuntk <rsuntk@yukiprjkt.my.id>
Co-authored-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
2025-06-14 20:03:30 +06:00
Wang Han
85f4e6ac27 Switch to prepare_creds/commit_creds (#2631)
Update API as per kernel doc recommends, also fix setup_groups refcount
leak while at it.
2025-06-14 20:01:36 +06:00
Paul
3921175e4c kernel: core_hook: intercept devpts via security_inode_permission LSM (#480)
`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-05 06:20:53 +06:00
rifsxd
ce37e17c87 kernel: added CMD_HOOK_MODE prctl to get the enabled su hook mode value 2025-05-21 18:07:41 +06:00
rifsxd
eed685507a kernel: rename KSU_WITH_KPROBES to KSU_KPROBES_HOOK for better self explanitory 2025-05-21 15:13:17 +06:00
backslashxx
980f71c1bd kernel: core_hook: fixup 217d230b (#402)
Reported-by: Trijal Saha <97483939+Trijal08@users.noreply.github.com>
2025-05-19 22:49:44 +06:00
backslashxx
9e150b2c44 ksud/installer: /odm handling
we move the folder out of system if it exists in real filesystem and it
is not a symlink.
this is already supported on init_event.rs so only handle_partition
logic was needed to make it happen

since KernelSU is using overlayfs, we need to move these out.

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

---------

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
2025-05-18 03:42:32 +06:00
backslashxx
217d230b61 kernel: expose KSU_LSM_SECURITY_HOOKS on Kconfig
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-18 03:23:12 +06:00
AlexLiuDev233
f369297be9 kernel: fix sometimes sucompat can not toggle by manager (#2484)
When the manager is already running, if other programs / kernel toggle
the sucompat enable status,
The manager "Disable SU Compat" toggle button can not work, kmesg print
"cmd enable su but no need to change."

I think we should still return reply_ok when the syscall value is
consistent with the kernel, which would fix the issue.
2025-03-10 22:16:03 +06:00
rifsxd
7a08683c74 kernel: remove unnecessary umount calls for configuration directories (evil modifications) 2025-02-25 19:48:20 +06:00
rifsxd
487e7d0012 kernel: simplify umount calls for configuration files 2025-02-25 15:37:12 +06:00
Wang Han
0038ba6566 Fix reference count leak in nuke_ext4_sysfs() (#2467)
We need to call path_put() to decrease the refcount.
2025-02-24 02:48:39 +06:00
backslashxx
097451d578 kernel: guard functionality that requires kprobes
Since upstream is now making kprobes a requirement, we adapt this tree to still allow
building with manual hooks in an easier way. Furthermore, this also allows a user to
build with manual hooks even with kprobes enabled.

Offending commit:
	kernel: remove unused CONFIG guard becuase GKI kernel enable kprobe by default
	upstream: https://github.com/tiann/KernelSU/commit/500ff9b

Other changes:
	ksud.c, stop_input_hook(), short-circuit redundant logic left by this change.
	cherry pick from: https://github.com/backslashxx/KernelSU/commit/a3d3e93

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
2025-02-23 21:00:59 +06:00
weishu
bb6c20339c kernel: add support for disable sucompat 2025-02-23 20:05:55 +06:00
rifsxd
42896dfab1 kernel: add umount calls for pixelify gphotos spoof configs and lsposed dex2oat bin 2025-02-22 04:40:28 +06:00
weishu
74171a2930 kernel: unregister sysfs for module's ext4 image 2025-02-21 17:02:33 +06:00
5ec1cff
87fc6b2784 kernel: clear securebits
fix adb shell cannot escape to root after https://github.com/tiann/KernelSU/pull/2381
2025-01-27 20:05:54 +06:00
Wang Han
a05b790da6 Avoid unnecessarily overriding capabilities (#2381)
Previously all capabilities were overridden with 0xffffffffffffffff,
which is
not what normal processes have. This causes PR_CAPBSET_DROP prctl
fail because it is dropping invalid caps. Fix it.

This fixes
https://gitlab.com/kalilinux/nethunter/apps/kali-nethunter-app/-/issues/378.

Co-Authored-By: 5ec1cff <56485584+5ec1cff@users.noreply.github.com>

Co-authored-by: 5ec1cff <56485584+5ec1cff@users.noreply.github.com>
2025-01-25 20:54:06 +06:00
rsuntk
0ada4ee5d4 kernel: improve get_cred_rcu guard
Signed-off-by: rsuntk <rissu.ntk@gmail.com>
2025-01-16 14:32:04 +06:00
rsuntk
95584df023 kernel: Add fallback if user didn't implement 'get_cred_rcu'
https://github.com/tiann/KernelSU/pull/2320

Signed-off-by: rsuntk <rissu.ntk@gmail.com>
2025-01-16 14:26:52 +06:00
SsageParuders
b18c39e911 Improve seccomp disable && Add locking to protect cred modifications in escape_to_root (#2320)
- When disabling Seccomp, ensure that current->sighand->siglock is held
during the operation.
- Locking to ensure safe access and modification of the `cred` structure
within the `escape_to_root` function.

---

I think this issue described in #2236 may have been caused by concurrent
read-write access without proper locking.

---------

Signed-off-by: SsageParuders<qinqingqing1025@gmail.com>
Signed-off-by: SsageParuders <qinqingqing1025@gmail.com>"
2025-01-16 14:18:26 +06:00
ExtremeXT
72739facc8 kernel: expose allowlist workaround as Kconfig option
Useful for situations where the SU allowlist is not kept after a reboot.
As per upstream this is only used for < 4.10 and Huawei HiSilicon devices.
but theres user reports having issues even on 4.14/4.19 samsung kernels.
Expose this option so users affected can opt-in.

Discussion:
	tiann#1249
	tiann#1346

References:
	tiann@f57d351
	tiann@b61cb30

Credits to respective authors:
	rhjdvsgsgks
	ExtremeXT
2025-01-07 04:59:09 +06:00
rifsxd
7ea1579bce kernel: try umount /system/etc/hosts & /system_ext 2024-12-31 11:14:39 +06:00
Loukious
a5f12ffe96 fix: reset ambient capabilities to resolve D-Bus permission issues 2024-12-27 22:39:38 +06:00
Rifat Azad
8fbddc959a Revert "kernel: added susfs v1.5.3"
This reverts commit bdf81c0880.
2024-12-24 08:21:10 +06:00
Rifat Azad
bdf81c0880 kernel: added susfs v1.5.3 2024-12-24 07:34:30 +06:00
Rifat Azad
1a84f69f5c Revert "[1.0] Drop Non-GKI Support (#1483)"
This reverts commit 97d70b40fc.
2024-12-24 06:54:08 +06:00
Rifat Azad
8d2b017c96 kernel: sync with upstream 2024-12-24 06:53:54 +06:00
backslashxx
36fb6085ef kernel: require path_umount backporting
Most kernel builders have to touch their kernel source code anyway so
we might as well tell them to backport path_umount to achieve some sort
of feature parity.

This enforces a path_umount backport, not a suggestion.
Its a requirement from now on.

You will backport path_umount and you will like it.
2024-12-17 22:45:23 +06:00
ExtremeXT
5f2c1eef9c kernel: expose allowlist workaround as Kconfig option
Useful for situations where the SU allowlist is not kept after a reboot.
As per upstream this is only used for < 4.10 and Huawei HiSilicon devices.
but theres user reports having issues even on 4.14/4.19 samsung kernels.
Expose this option so users affected can opt-in.

Discussion:
	tiann#1249
	tiann#1346

References:
	tiann@f57d351
	tiann@b61cb30

Credits to respective authors:
	rhjdvsgsgks
	ExtremeXT
2024-12-17 20:33:55 +06:00
Rifat Azad
a545a3e81c kernel: slightly polish up code 2024-12-16 02:42:33 +06:00
Rifat Azad
98a692370f kernel: Removed SuSFS Patch 2024-12-13 06:21:40 +06:00
Rifat Azad
e15516040d Revert "kernel: susfs: CONFIG_KSU_SUSFS_INFO syscall to get susfs version & variant"
This reverts commit b78c9adf49.
2024-12-13 06:21:38 +06:00
Rifat Azad
b78c9adf49 kernel: susfs: CONFIG_KSU_SUSFS_INFO syscall to get susfs version & variant 2024-12-06 22:48:14 +06:00
Rifat Azad
e1d30d55af kernel: implement SuSFS v1.5.2 2024-12-04 16:30:28 +06:00
Huy Minh
3acb13df65 kernel: Relax dentry_path_raw compare in core_hook (#2041)
On Android-x86 (or BlissOS) it initialize Android by using switch_root
or chroot, when checking a path with dentry_path_raw() it will show the
whole real path instead of the path that we want.

Relax the checking requirement by using strstr to look for
"/system/packages.list" in the string instead of requiring the path to
be "/system/packages.list"

This fixes #1783

Signed-off-by: hmtheboy154 <buingoc67@gmail.com>
2024-09-07 10:59:06 +08:00
Ylarod
97d70b40fc [1.0] Drop Non-GKI Support (#1483)
Co-authored-by: weishu <twsxtd@gmail.com>
2024-06-01 14:50:46 +08:00
weishu
5d6ef355ae kernel: Allow to use in Private Space 2024-05-16 12:03:58 +08:00
weishu
2efefcea72 kernel: use library import 2024-04-27 09:55:24 +08:00
weishu
cd73307cd4 kernel: refactor PR_REAL_REGS 2024-04-26 13:25:29 +08:00
D8G Official
ae8ffe2c10 Fix missing semicolon (#1551)
Fix build non gki kernel
2024-03-28 20:22:00 +08:00
Coconut
4584aa7f4e kernel:Add Huawei hisi check (#1545)
Use huawei_hisi_check.h to determine whether it is an old Huawei
HiSilicon device.
Solve:  
1. Compatible with non-GKI Huawei HiSilicon devices
2. Solve different bugs in EMUI of different system versions
3. Does not affect other devices
2024-03-28 14:20:00 +08:00
weishu
ea0ee0563a kernel: Fix misleading log 2024-03-27 17:29:03 +08:00
Jprimero15
37410f85a4 kernel: guard "umount for uid" logprint with CONFIG_KSU_DEBUG (#1519)
Its too spammy to be on non-debug mode.
2024-03-24 21:42:23 +08:00
weishu
d8671b14d1 kernel: clean memory when exit 2024-03-24 16:41:53 +08:00
weishu
478fda6712 kernel: remove become_manager and minor refactors 2024-03-24 11:20:43 +08:00