Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors SELinux policy duplication in the kernel SELinux integration to use a simpler “serialize + deserialize” approach instead of hand-copying selected policydb structures.
Changes:
- Replace the custom partial/deep copy logic for
policydbwithpolicydb_write()into a buffer followed bypolicydb_read()into a fresh policydb. - Simplify policy destruction by calling
policydb_destroy()directly. - Add a small “config” fixup in the serialized policy buffer before reading it back.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AlexLiuDev233
added a commit
to ReSukiSU/ReSukiSU
that referenced
this pull request
May 3, 2026
use policydb_read/policydb_write for dup_policy add same way for nongki to fix the problem as below <3>[ 4.086580] BUG: sleeping function called from invalid context at security/selinux/ss/hashtab.c:47 <3>[ 4.086583] in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 1, name: init <4>[ 4.086586] CPU: 7 PID: 1 Comm: init Tainted: G W 5.4.302-qgki-g342369d45f2a #451 <4>[ 4.086589] Hardware name: Qualcomm Technologies, Inc. Blair QRD NOPMI (DT) <4>[ 4.086591] Call trace: <4>[ 4.086599] dump_backtrace+0x0/0x19c <4>[ 4.086603] dump_stack+0x90/0xcc <4>[ 4.086606] ___might_sleep+0x110/0x12c <4>[ 4.086610] hashtab_insert+0x3c/0x18c <4>[ 4.086614] add_type.llvm.13442088749150705041+0x98/0x1f0 <4>[ 4.086616] ksu_type+0x28/0x5c <4>[ 4.086618] apply_kernelsu_rules+0xb8/0x5b4 <4>[ 4.086621] ksu_initialize_selinux+0x10/0x24 <4>[ 4.086623] ksu_handle_execveat_ksud+0x1a8/0x388 <4>[ 4.086626] ksu_handle_execveat+0xec/0xf4 <4>[ 4.086629] __arm64_sys_execve+0x50/0x84 <4>[ 4.086632] el0_svc_common+0xdc/0x1ac <4>[ 4.086634] el0_svc_handler+0x24/0x64 <4>[ 4.086637] el0_svc+0x8/0x140 for backslashxx's afraid of time window to race, use lock sel_mutex to solve Thanks for 5ec1cff's idea and help! Off topic: I don't want use stop_machine like: backslashxx/KernelSU@4309f10 backslashxx/KernelSU@454b0c9 Even only in sel_mutex/policy_rwlock not exported This severely impacts performance [Adapted from upstream pull request tiann/KernelSU#3350] Co-authored-by: 5ec1cff <ewtqyqyewtqyqy@gmail.com> Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
AlexLiuDev233
added a commit
to ReSukiSU/ReSukiSU
that referenced
this pull request
May 3, 2026
use policydb_read/policydb_write for dup_policy add same way for nongki to fix the problem as below <3>[ 4.086580] BUG: sleeping function called from invalid context at security/selinux/ss/hashtab.c:47 <3>[ 4.086583] in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 1, name: init <4>[ 4.086586] CPU: 7 PID: 1 Comm: init Tainted: G W 5.4.302-qgki-g342369d45f2a #451 <4>[ 4.086589] Hardware name: Qualcomm Technologies, Inc. Blair QRD NOPMI (DT) <4>[ 4.086591] Call trace: <4>[ 4.086599] dump_backtrace+0x0/0x19c <4>[ 4.086603] dump_stack+0x90/0xcc <4>[ 4.086606] ___might_sleep+0x110/0x12c <4>[ 4.086610] hashtab_insert+0x3c/0x18c <4>[ 4.086614] add_type.llvm.13442088749150705041+0x98/0x1f0 <4>[ 4.086616] ksu_type+0x28/0x5c <4>[ 4.086618] apply_kernelsu_rules+0xb8/0x5b4 <4>[ 4.086621] ksu_initialize_selinux+0x10/0x24 <4>[ 4.086623] ksu_handle_execveat_ksud+0x1a8/0x388 <4>[ 4.086626] ksu_handle_execveat+0xec/0xf4 <4>[ 4.086629] __arm64_sys_execve+0x50/0x84 <4>[ 4.086632] el0_svc_common+0xdc/0x1ac <4>[ 4.086634] el0_svc_handler+0x24/0x64 <4>[ 4.086637] el0_svc+0x8/0x140 for backslashxx's afraid of time window to race, use lock sel_mutex to solve Thanks for 5ec1cff's idea and help! Off topic: I don't want use stop_machine like: backslashxx/KernelSU@4309f10 backslashxx/KernelSU@454b0c9 Even only in sel_mutex/policy_rwlock not exported This severely impacts performance [Adapted from upstream pull request tiann/KernelSU#3350] Co-authored-by: 5ec1cff <ewtqyqyewtqyqy@gmail.com> Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
AlexLiuDev233
added a commit
to ReSukiSU/ReSukiSU
that referenced
this pull request
May 3, 2026
use policydb_read/policydb_write for dup_policy add same way for nongki to fix the problem as below <3>[ 4.086580] BUG: sleeping function called from invalid context at security/selinux/ss/hashtab.c:47 <3>[ 4.086583] in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 1, name: init <4>[ 4.086586] CPU: 7 PID: 1 Comm: init Tainted: G W 5.4.302-qgki-g342369d45f2a #451 <4>[ 4.086589] Hardware name: Qualcomm Technologies, Inc. Blair QRD NOPMI (DT) <4>[ 4.086591] Call trace: <4>[ 4.086599] dump_backtrace+0x0/0x19c <4>[ 4.086603] dump_stack+0x90/0xcc <4>[ 4.086606] ___might_sleep+0x110/0x12c <4>[ 4.086610] hashtab_insert+0x3c/0x18c <4>[ 4.086614] add_type.llvm.13442088749150705041+0x98/0x1f0 <4>[ 4.086616] ksu_type+0x28/0x5c <4>[ 4.086618] apply_kernelsu_rules+0xb8/0x5b4 <4>[ 4.086621] ksu_initialize_selinux+0x10/0x24 <4>[ 4.086623] ksu_handle_execveat_ksud+0x1a8/0x388 <4>[ 4.086626] ksu_handle_execveat+0xec/0xf4 <4>[ 4.086629] __arm64_sys_execve+0x50/0x84 <4>[ 4.086632] el0_svc_common+0xdc/0x1ac <4>[ 4.086634] el0_svc_handler+0x24/0x64 <4>[ 4.086637] el0_svc+0x8/0x140 for backslashxx's afraid of time window to race, use lock sel_mutex to solve Thanks for 5ec1cff's idea and help! Off topic: I don't want use stop_machine like: backslashxx/KernelSU@4309f10 backslashxx/KernelSU@454b0c9 Even only in sel_mutex/policy_rwlock not exported This severely impacts performance [Adapted from upstream pull request tiann/KernelSU#3350] Co-authored-by: 5ec1cff <ewtqyqyewtqyqy@gmail.com> Signed-off-by: AlexLiuDev233 <wzylin11@outlook.com>
pershoot
pushed a commit
to KernelSU-Next/KernelSU-Next
that referenced
this pull request
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.