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
2023-06-16 19:53:15 +08:00
2023-06-16 19:53:15 +08:00
2022-12-09 22:03:55 +08:00
2023-06-13 12:11:12 +08:00
2023-06-13 12:11:12 +08:00
2023-06-13 12:11:12 +08:00
2023-06-13 12:11:12 +08:00
2023-06-13 12:11:12 +08:00
2023-06-13 12:11:12 +08:00

English | 简体中文 | 繁體中文 | 日本語 | Portuguese-Brazil | Türkçe

KernelSU

A Kernel based root solution for Android devices.

Features

  1. Kernel-based su and root access management.
  2. Module system based on overlayfs.

Compatibility State

KernelSU officially supports Android GKI 2.0 devices(with kernel 5.10+), old kernels(4.14+) is also compatible, but you need to build kernel yourself.

WSA and containter-based Android should also work with KernelSU integrated.

And the current supported ABIs are : arm64-v8a and x86_64

Usage

Installation

Build

How to build?

Discussion

License

  • Files under kernel directory are GPL-2
  • All other parts except kernel directory are GPL-3

Credits

Description
No description provided
Readme GPL-3.0 60 MiB
Languages
Kotlin 67.1%
C 20%
Rust 11.1%
Shell 0.9%
Makefile 0.4%
Other 0.4%