Skip to content

Commit cd9bf46

Browse files
committed
process tagging bullshit
for: 3378 https://elixir.bootlin.com/linux/v7.0-rc6/source/arch/arm64/include/asm/thread_info.h https://elixir.bootlin.com/linux/v7.0-rc6/source/arch/arm/include/asm/thread_info.h Update sucompat.c 1 for: tiann#3378 ximi-mojito-test/mojito_krenol@d961afa [ 72.716077] KernelSU: task_alloc: uid: 10204 pid: 5188 [ 72.716516] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5576 comm: com.termux [ 72.718024] KernelSU: task_alloc: uid: 10204 pid: 5188 [ 72.718604] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5576 comm: com.termux [ 72.733396] KernelSU: task_alloc: uid: 10204 pid: 5576 [ 72.734067] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5580 comm: login [ 72.762384] KernelSU: task_alloc: uid: 10204 pid: 5576 [ 72.764152] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5581 comm: login [ 72.769936] KernelSU: task_alloc: uid: 10204 pid: 5576 [ 72.770506] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5582 comm: login [ 72.777585] KernelSU: task_alloc: uid: 10204 pid: 5576 [ 72.779238] KernelSU: task_alloc: uid: 10204 pid: 5576 [ 72.782688] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5584 comm: login [ 72.792786] KernelSU: task_alloc: uid: 10204 pid: 5576 [ 72.795331] KernelSU: task_alloc: uid: 10204 pid: 5576 [ 72.796197] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5586 comm: login [ 72.810608] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5586 comm: bash [ 72.820124] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5576 comm: login [ 72.845099] KernelSU: task_alloc: uid: 10204 pid: 5188 [ 72.854435] KernelSU: task_alloc: uid: 10204 pid: 5568 [ 72.877155] KernelSU: task_alloc: uid: 10204 pid: 5188 [ 73.142322] KernelSU: task_alloc: uid: 10204 pid: 5546 [ 73.318306] KernelSU: task_alloc: uid: 10204 pid: 5188 [ 73.324878] KernelSU: task_alloc: uid: 10204 pid: 5600 [ 77.861947] KernelSU: task_alloc: uid: 10204 pid: 5576 [ 77.865438] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5619 comm: bash [ 77.870812] KernelSU: faccessat su->sh! [ 77.870877] KernelSU: faccessat su->sh! [ 77.871118] KernelSU: sys_execve su->ksud! [ 77.871199] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5619 comm: sh [ 77.876575] KernelSU: sys_reboot: intercepted call! magic: 0xdeadbeef id: -889275714 [ 77.876581] KernelSU: ksu fd installed: 3 for pid 5619 [ 77.876582] KernelSU: [5619] install ksu fd: 3 [ 77.876671] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5619 comm: ksud [ 77.877275] KernelSU: ksu fd released [ 81.746578] KernelSU: task_alloc: uid: 0 pid: 5619 [ 81.747869] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5709 comm: sh [ 87.314972] KernelSU: task_alloc: uid: 0 pid: 5619 [ 87.316569] KernelSU: ksu_bprm_check: ksu managed task found with pid: 5721 comm: sh
1 parent a7aaf41 commit cd9bf46

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

kernel/feature/sucompat.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,14 @@ static __always_inline bool is_su_allowed(const void **ptr_to_check)
6666
if (likely(!!current->seccomp.mode))
6767
return false;
6868

69+
if (test_thread_flag(TIF_KSU_MANAGED) && current_uid().val != 2000)
70+
goto ptr_check;
71+
6972
// with seccomp check above, we can make this neutral
7073
if (!ksu_is_allow_uid_for_current(current_uid().val))
7174
return false;
7275

76+
ptr_check;
7377
// first check the pointer-to-pointer
7478
if (unlikely(!ptr_to_check))
7579
return false;

kernel/hook/core_hook.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ LSM_HANDLER_TYPE ksu_handle_setuid(struct cred *new, const struct cred *old)
6767

6868
kill_seccomp:
6969
disable_seccomp();
70+
71+
if (IS_ENABLED(CONFIG_KSU_DEBUG))
72+
pr_info("%s: tag task with uid: %d pid: %d comm: %s \n", __func__, new_uid, current->pid, current->comm);
73+
74+
set_thread_flag(TIF_KSU_MANAGED);
7075
return 0;
7176
}
7277

@@ -77,6 +82,13 @@ LSM_HANDLER_TYPE ksu_bprm_check(struct linux_binprm *bprm)
7782
ksu_sulog_emit_bprm((const char *)bprm->filename);
7883
#endif
7984

85+
#if 0
86+
if (unlikely(test_thread_flag(TIF_KSU_MANAGED))) {
87+
pr_info("%s: ksu managed task found with pid: %d comm: %s \n", __func__, current->pid, current->comm);
88+
// clear_thread_flag(TIF_KSU_MANAGED);
89+
}
90+
#endif
91+
8092
return 0;
8193
}
8294

kernel/kernel_compat.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,4 +349,19 @@ static inline ksu_kuid_t current_uid() { return *(ksu_kuid_t *)(&current_cred()-
349349
static inline ksu_kuid_t current_euid() { return *(ksu_kuid_t *)(&current_cred()->euid); }
350350
#endif // < 3.14
351351

352+
// its free real estate, this is ulong so wordsize.
353+
// https://elixir.bootlin.com/linux/v7.0-rc6/source/arch/arm64/include/asm/thread_info.h
354+
// https://elixir.bootlin.com/linux/v7.0-rc6/source/arch/arm/include/asm/thread_info.h
355+
#if defined(CONFIG_64BIT)
356+
#define TIF_KSU_MANAGED 60
357+
#define TIF_KSU_RESERVED_61 61
358+
#define TIF_KSU_RESERVED_62 62
359+
#define TIF_KSU_RESERVED_63 63
360+
#else
361+
#define TIF_KSU_MANAGED 28
362+
#define TIF_KSU_RESERVED_29 29
363+
#define TIF_KSU_RESERVED_30 30
364+
#define TIF_KSU_RESERVED_31 31
365+
#endif
366+
352367
#endif // __KSU_H_KERNEL_COMPAT

0 commit comments

Comments
 (0)