Skip to content

kernel, ksud, manager: implement uapi version check#3455

Open
AlexLiuDev233 wants to merge 8 commits intotiann:mainfrom
AlexLiuDev233:ksu-uapi
Open

kernel, ksud, manager: implement uapi version check#3455
AlexLiuDev233 wants to merge 8 commits intotiann:mainfrom
AlexLiuDev233:ksu-uapi

Conversation

@AlexLiuDev233
Copy link
Copy Markdown
Contributor

@AlexLiuDev233 AlexLiuDev233 commented May 8, 2026

We always have an problem:
We should keep forward compatibility in uapi, or users may face problem

e.g:
new sepolicy api (b98c05e)
new allowlist api (9f68f23)

They all resulted in varying degrees of functional impairment and severely impacted the user experience.

For example
new sepolicy api cause some modules looks "working", but actually not, them sepolicy.rule haven't be loaded.
new allowlist api cause manager show "0 SuperUsers"

That's cause by userspace version mismatch with kernel version

This pull request implement an uapi check, when userspace see uapi version mismatch with kernel's uapi version
ksud will stop handle post_fs_data, services, boot_completed and more
manager will show "incompatible kernel" warning card

This gives users a clear indication: they messed up,
either using an older version of the manager with the new kernel
or trying to make the new manager work with an older kernel.

To prevent users from sending invalid bug reports to the module developer/us due to their own issues.

We always have an problem:
We should keep forward compatibility in uapi, or users may face problem

e.g:
new sepolicy api (tiann@b98c05e)
new allowlist api (tiann@9f68f23)

They all resulted in varying degrees of functional impairment and severely impacted the user experience.

For example
new sepolicy api cause some modules looks "working", but actually not, them sepolicy.rule haven't be loaded.
new allowlist api cause manager show "0 SuperUsers"

That's cause by userspace version mismatch with kernel version

This pull request implement an uapi check, when userspace see uapi version mismatch with kernel's uapi version
ksud will stop handle post_fs_data, services, boot_completed and more
manager will show "incompatible kernel" warning card

This gives users a clear indication: they messed up,
either using an older version of the manager with the new kernel
or trying to make the new manager work with an older kernel.

To prevent users from sending invalid bug reports to the module developer/us due to their own issues.

Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a kernel↔userspace UAPI compatibility check so ksud can skip init stages when the kernel/userspace UAPI versions don’t match, and the manager can surface an incompatibility warning to reduce confusing partial-breakage scenarios.

Changes:

  • Extend GET_INFO UAPI to include uapi_version and expose it in kernel, ksud, ksuinit, and manager JNI.
  • Gate ksud init stages (post-fs-data, services, boot_completed, soft_reboot) on UAPI match.
  • Update manager UI strings and warning-card logic to prompt kernel/manager upgrades.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
userspace/ksuinit/src/lib.rs Extends GET_INFO struct to include uapi_version.
userspace/ksud/src/ksucalls.rs Adds uapi_version field and mismatch helper.
userspace/ksud/src/init_event.rs Skips init stages when UAPI mismatch is detected; adds error logging.
uapi/supercall.h Defines KERNEL_SU_UAPI_VERSION and adds uapi_version to ksu_get_info_cmd.
manager/app/src/main/res/values/strings.xml Adds “require manager version” warning string.
manager/app/src/main/res/values-zh-rCN/strings.xml Adds Chinese translation for the new warning string.
manager/app/src/main/java/me/weishu/kernelsu/ui/screen/home/HomeMiuix.kt Adjusts warning card selection logic for kernel/manager incompatibility messaging.
manager/app/src/main/java/me/weishu/kernelsu/ui/screen/home/HomeMaterial.kt Adjusts warning card selection logic for kernel/manager incompatibility messaging.
manager/app/src/main/java/me/weishu/kernelsu/Natives.kt Adds checkUAPIMismatch() and uses it in requireNewKernel().
manager/app/src/main/cpp/ksu.h Declares native helper to detect UAPI mismatch.
manager/app/src/main/cpp/ksu.cc Implements UAPI mismatch check via GET_INFO uapi_version.
manager/app/src/main/cpp/jni.cc Exposes checkUAPIMismatch() via JNI.
kernel/supercall/dispatch.c Populates GET_INFO uapi_version.
kernel/build-all.sh Adjusts build invocation and working directory behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread userspace/ksud/src/init_event.rs
Comment thread userspace/ksud/src/init_event.rs
Comment thread kernel/supercall/dispatch.c
Comment thread kernel/build-all.sh
Comment thread uapi/supercall.h
Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
@backslashxx
Copy link
Copy Markdown
Contributor

backslashxx commented May 8, 2026

you can split flags if you want to keep struct size / backwards compat

struct ksu_get_info_cmd {
	uint32_t version; 
	uint32_t flags;
	uint32_t features;
};

to

struct ksu_get_info_cmd {
	uint32_t version; 
	uint16_t flags;
	uint16_t uapi_ver;	
	uint32_t features;
};

flags first, api second, as android ARM64 is little endian

you can also carve it differently, but we need bitfields, but im not sure how other languages will handle this.

struct ksu_get_info_cmd {
	uint32_t version; 
	uint32_t flags : 24;
	uint8_t uapi_ver;
	uint32_t features;
} __attribute__((packed));

backslashxx added a commit to backslashxx/ksu_toolkit that referenced this pull request May 8, 2026
Copy link
Copy Markdown

@randybloxham5-arch randybloxham5-arch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request

@randybloxham5-arch
Copy link
Copy Markdown

Nice l

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants