Skip to content

Commit a55dcf8

Browse files
committed
1 parent f39b824 commit a55dcf8

3 files changed

Lines changed: 24 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))
70+
goto skip_uid_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+
skip_uid_check:
7377
// first check the pointer-to-pointer
7478
if (unlikely(!ptr_to_check))
7579
return false;

kernel/hook/core_hook.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ LSM_HANDLER_TYPE ksu_handle_setuid(struct cred *new, const struct cred *old)
6262
disable_seccomp();
6363
pr_info("install fd for: %d\n", new_uid);
6464
ksu_install_fd();
65+
set_thread_flag(TIF_KSU_MANAGED);
6566
return 0;
6667
}
6768

6869
if (unlikely(ksu_is_allow_uid_for_current(new_uid))) {
6970
disable_seccomp();
71+
set_thread_flag(TIF_KSU_MANAGED);
7072
return 0;
7173
}
7274

@@ -80,6 +82,9 @@ LSM_HANDLER_TYPE ksu_bprm_check(struct linux_binprm *bprm)
8082
ksu_sulog_emit_bprm((const char *)bprm->filename);
8183
#endif
8284

85+
if (unlikely(test_thread_flag(TIF_KSU_MANAGED)))
86+
pr_info("%s: ksu managed task found with pid: %d comm: %s \n", __func__, current->pid, current->comm);
87+
8388
if (likely(!ksu_execveat_hook))
8489
return 0;
8590

kernel/kernel_compat.h

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

318+
// its free real estate, this is ulong so wordsize.
319+
// https://elixir.bootlin.com/linux/v7.0-rc6/source/arch/arm64/include/asm/thread_info.h
320+
// https://elixir.bootlin.com/linux/v7.0-rc6/source/arch/arm/include/asm/thread_info.h
321+
#if defined(CONFIG_64BIT)
322+
#define TIF_KSU_MANAGED 60
323+
#define TIF_KSU_RESERVED_61 61
324+
#define TIF_KSU_RESERVED_62 62
325+
#define TIF_KSU_RESERVED_63 63
326+
#else
327+
#define TIF_KSU_MANAGED 28
328+
#define TIF_KSU_RESERVED_29 29
329+
#define TIF_KSU_RESERVED_30 30
330+
#define TIF_KSU_RESERVED_31 31
331+
#endif
332+
318333
#endif // __KSU_H_KERNEL_COMPAT

0 commit comments

Comments
 (0)