75 Commits

Author SHA1 Message Date
Wang Han
78bf2493bf
Convert devpts domain to ksu_file (#1801)
AOSP sepolicy does not allow appdomain to open pts. Hence, convert
devpts domain to ksu_file to allow any access.
2024-06-03 21:21:39 +08:00
Ylarod
898e9d4f8c
[1.0] Drop Non-GKI Support (#1483)
Co-authored-by: weishu <twsxtd@gmail.com>
2024-06-01 14:50:46 +08:00
weishu
98757bcdb3 kernel: transition devpts in kernel 2024-05-08 21:15:49 +08:00
5ec1cff
935dc18faa
su: allocate new pty (#1693) 2024-05-07 19:02:59 +08:00
weishu
efbc07fde3 kernel: use library import 2024-04-27 09:55:24 +08:00
Coconut
4f05fe226e
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
9a04211051 kernel: Let the kernel choose who is qualified to be the manager. 2024-03-23 21:48:03 +08:00
weishu
808342bf04 kernel: Fix sepolicy on ColorOS14 2024-03-20 17:43:37 +08:00
Coconut
e3998c0744
kernel:Compatible with devices based on Huawei EMUI10 (#1447)
EMUI 10 kernel version is 4.14.xxx.  
The SELinux of Huawei's modified EMUI10 kernel is still similar to the
EMUI 9 version. This commit not support HarmonyOS 2 based EMUI 10.
2024-03-14 15:18:59 +08:00
weishu
01b685ce58
kernel: Allow system_server to kill su process 2024-02-20 18:16:43 +08:00
weishu
e934bfb648 kernel: Add init selinux rules. 2024-01-15 20:28:53 +08:00
Ylarod
5b920f8230
kernel: fix secctx mem leak (#1283)
Co-authored-by: weishu <twsxtd@gmail.com>
2024-01-14 11:15:52 +08:00
Ylarod
f37cc16117
Correctly handle is_ksu_domain, close #972 (#1246)
fix #972
2024-01-04 14:14:31 +08:00
The_second_Tom
dcd9d65c92
kernel: adapt to kernel above 6.4 (#1196)
Above kernel 6.4, there is no struct_avc member in selinux_state.
2023-12-11 00:13:06 +08:00
kevios12
7a1767b4c9
kernel: fix Modules install stuck on kernel 4.4 (#1059) 2023-10-22 23:40:53 +08:00
weishu
ce892bc439 kernel: don't umount for non zygote child process. fixes #1054,#1049,#1045 2023-10-19 17:29:10 +08:00
weishu
340595276f kernel: Add selinux rules for module umount 2023-10-09 18:09:54 +08:00
longhuan1999
54ee400dc5
kernel: Adapt to low version Android init process (#973)
1. Adapt to low version Android init process
2. Add stop hook output
3. Fix output with missing line breaks
2023-10-02 12:00:24 +08:00
weishu
e3e77fde78 kernel: authorize the newly type for all roles. refer: http://aospxref.com/kernel-android12-5.10-lts/xref/security/selinux/ss/policydb.c#950 2023-07-01 20:54:13 +08:00
weishu
d675662862 kernel: add some log 2023-07-01 19:35:28 +08:00
weishu
980f1d09bc kernel: allow kernel to mount loop devices. close #514 2023-06-26 19:29:29 +08:00
Juhyung Park
bd8434f4f4
Hook improvements (take 2) (#563)
Hi @tiann.

Thanks for the great project, I had great fun playing around with it.

This PR mainly tries to further minimize the possible delays caused by
KernelSU hooking.

There are 3 major changes:
- Processes with 0 < UID < 2000 are blocked straight-up before going
through the allow_list.
I don't see any need for such processes to be interested in root, and
this allows returning early before going through a more expensive
lookup.
If there's an expected breakage due to this change, I'll remove it. Let
me know.
- A page-sized (4K) bitmap is added.
This allows O(1) lookup for UID <= 32767.
This speeds up `ksu_is_allow_uid()` by about 4.8x by sacrificing a 4K
memory. IMHO, a good trade-off.
Most notably, this reduces the 99.999% result previously from worrying
milliseconds scale to microseconds scale.
For UID > 32767, another page-sized (4K) sequential array is used to
cache allow_list.

Compared to the previous PR #557, this new approach gives another nice
25% performance boost in average, 63-96% boost in worst cases.

Benchmark results are available at
https://docs.google.com/spreadsheets/d/1w_tO1zRLPNMFRer49pL1TQfL6ndEhilRrDU1XFIcWXY/edit?usp=sharing

Thanks!

---------

Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
2023-06-16 19:53:15 +08:00
Soo-Hwan Na
6d1ee60d67
kernel/selinux: Need to force include errno.h sometimes (#572)
- Seen with Linux 4.14 kernel with error message:

In file included from ../drivers/android/kernelsu/selinux/sepolicy.c:1:
In file included from ../drivers/android/kernelsu/selinux/sepolicy.h:6:
In file included from ../security/selinux/ss/policydb.h:30: In file
included from ../security/selinux/ss/avtab.h:26:
../security/selinux/include/security.h:240:10: error: use of undeclared
identifier 'EIDRM'
        return -EIDRM;
                ^
  CC      drivers/base/transport_class.o
  CC      kernel/rcu/update.o
../security/selinux/include/security.h:246:10: error: use of undeclared
identifier 'ENOENT'
        return -ENOENT;
                ^
2023-06-06 16:42:45 +08:00
weishu
53be8612c8 kernel: support setting selinux context for profile 2023-06-06 16:35:25 +08:00
weishu
8858cc899e kernel: remove no-macro-redefined 2023-05-22 10:50:04 +08:00
Abdelhay-Ali
08e3580646
make huawei hi6250 4.9.319 kernel compile (#431) 2023-04-27 13:30:04 +08:00
3452841752
selinux: use grep to check api supports (#402)
This checks `selinux_state` and `current_sid` supports in a raw way.
Feels more reliable than the version checks.

Supersedes #401, fixes #280, fixes #400.
2023-04-20 15:22:03 +08:00
tiann
0c9ecf3abc kernel: always apply sepolicy rules even if selinux is permissive 2023-04-18 14:15:37 +08:00
Coconut
7be61b9657
Make Huawei 4.9 Kernel compiler Happy and Does not affect other kernels (#374)
Adapt to SELinux with Huawei 4.9.xxx kernel without affecting other
mainstream kernels
2023-04-13 17:08:05 +08:00
Dhruv Gera
7be405e4e4
selinux: Update 4.9 to the correct check (#324)
4.9's last release aka 4.9.337 still needs the same fallbacks as 4.9.212
and breaks otherwise, upgrade this to fix compilation

Tested and working on POCO F1, 4.9.337
2023-03-27 21:26:37 +08:00
weishu
54d2962a0d kernel: add_type for 5.4 is supported actually. 2023-03-03 11:17:17 +07:00
weishu
849164e4de kernel: fix compile err 2023-02-20 20:06:56 +07:00
weishu
83b0aed52a kernel: apply rules should return success when selinux is disabled or permissive 2023-02-20 18:13:53 +07:00
Enes Sastim
8fbdd996de
use selinux_state for 4.9.212+ (#245)
_selinux_state_ is backported to 4.9 kernel with the 4.9.212 release,
use it to fix the build.
many thanks to @reallysnow for figuring this out.
inspired by
d7c2c5f02a
2023-02-15 11:39:16 +08:00
weishu
b024b5d006 kernel: support add_type for 4.x kernel
Co-authored-by: Ookiineko <chiisaineko@protonmail.com>
2023-02-14 19:08:18 +07:00
weishu
d5bab2317e kernel: correctly handle add attr 2023-02-14 18:52:48 +07:00
weishu
f9b3218ded kernel: fix policydb length 2023-02-14 14:41:00 +07:00
weishu
20ff530962 kernel: fix sepolicy apply may not work #227
Co-authored-by: sekaiacg <sekaiacg@gmail.com>
2023-02-13 09:12:31 +07:00
Aquarius223
6d15cb7e33
kernel: Fix f6967d2c lost parameters after ack-linux 4.14.y (>=163) (#234)
* [android-4.14-stable tree:
https://github.com/aosp-mirror/kernel_common/commit/5d0939e1]

Change-Id: Ice92dd83df4c4f1ae272156cb57f95998e45819f

Co-authored-by: stic-server-open <1138705738@qq.com>
2023-02-12 18:11:28 +08:00
weishu
f6967d2cfb kernel: reset avc cache for sepolicy
Co-authored-by: sekaiacg <sekaiacg@gmail.com>
2023-02-12 13:09:00 +07:00
Aquarius223
66284bfbe3
kernel: Correctly judge the version of selinux_state (#214)
* Merged related changes in android-common-kernel-4.14.163 [1] Handle
correct checks for older versions (below 4.14.163, 4.9, 4.4)
* fixes 14be7562, it is required in 4.14.163 kernel, it is not needed in
4.14.163 and later

[1]: https://github.com/MiCode/Xiaomi_Kernel_OpenSource/commits/1cfd8419

Change-Id: Iade104312d058a249667ca836259d5608418bb55

Co-authored-by: admin <paper@localhost>
2023-02-07 15:02:48 +08:00
初羽
14be75629b
kernel: selinux: Fix build error (#213)
* d77ab8d although fixed some typo, but since there is no include avc.h,
this will cause the build to fail
* Error:


/mnt/HDD/fish/aospa/kernel/msm-4.9/drivers/staging/ksu/selinux/selinux.c:60:2:
error: use of undeclared identifier 'selinux_enforcing'
        selinux_enforcing = enforce;
        ^

/mnt/HDD/fish/aospa/kernel/msm-4.9/drivers/staging/ksu/selinux/selinux.c:81:9:
error: use of undeclared identifier 'selinux_enforcing'
        return selinux_enforcing;
               ^
2 errors generated.

Change-Id: I4cc8917b2b73ca467873222e02d498da8718988e
2023-02-07 09:50:55 +08:00
小さい猫
d77ab8dbff
kernel: selinux: fix more typos introduced in #166 (#212)
i didn't realize these typos in #181

Signed-off-by: Ookiineko <chiisaineko@protonmail.com>
2023-02-06 16:31:26 +08:00
小さい猫
199f5cc223
fix some typos introduced in #166 (#181)
Signed-off-by: Ookiineko <chiisaineko@protonmail.com>
Co-authored-by: f19 <58457605+F-19-F@users.noreply.github.com>
Co-authored-by: Scirese <nuclearlight91@gmail.com>
2023-02-02 23:38:04 +08:00
f19
4f2b8b7077
kernel: backport to 4.4 (#166)
These changes make KernelSU work on kernel4.4
[link](https://github.com/F-19-F/android_kernel_oneplus_msm8998).
LINUX_VERSION_CODE macro changes have been vertied on 4.4 4.9 4.14.
For kernel 4.4,just pick two commits
* [introduce
KernelSU](2993524f2f)
* [allow init exec ksud under
nosuid](3df9df42a6)
2023-02-01 19:48:36 +08:00
skbeh
46913671a8
kernel, ksud: collect binaries into /data/adb/ksu (#161) 2023-02-01 17:58:58 +08:00
weishu
ab6d483c32 kernel: fix sepolicy rule which contains * 2023-01-31 20:51:02 +07:00
weishu
b9e27621ee kernel: support sepolicy 2023-01-31 18:54:31 +07:00
weishu
413a8d0a2f kernel: support selinux state transition 2023-01-26 16:05:14 +07:00
weishu
1852652029 kernel: add sepolicy calls 2023-01-26 16:05:14 +07:00