Skip to content

Commit 6eed83d

Browse files
committed
1 parent ea98414 commit 6eed83d

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,11 +66,15 @@ 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
kuid_t current_uid = current_uid();
7174
if (!ksu_is_allow_uid_for_current( ksu_get_uid_t(current_uid) ))
7275
return false;
7376

77+
skip_uid_check:
7478
// first check the pointer-to-pointer
7579
if (unlikely(!ptr_to_check))
7680
return false;

kernel/hook/core_hook.c

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

6970
if (unlikely(ksu_is_allow_uid_for_current(new_uid))) {
7071
disable_seccomp();
72+
set_thread_flag(TIF_KSU_MANAGED);
7173
return 0;
7274
}
7375

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

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+
8489
if (likely(!ksu_execveat_hook))
8590
return 0;
8691

kernel/kernel_compat.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,19 @@ static inline u64 ksu_ktime_get_ns(void) { return ktime_to_ns(ktime_get()); }
278278

279279
static inline void ksu_kfree_byref(void *buf) { kfree(*(void **)buf); }
280280

281+
// its free real estate, this is ulong so wordsize.
282+
// https://elixir.bootlin.com/linux/v7.0-rc6/source/arch/arm64/include/asm/thread_info.h
283+
// https://elixir.bootlin.com/linux/v7.0-rc6/source/arch/arm/include/asm/thread_info.h
284+
#if defined(CONFIG_64BIT)
285+
#define TIF_KSU_MANAGED 60
286+
#define TIF_KSU_RESERVED_61 61
287+
#define TIF_KSU_RESERVED_62 62
288+
#define TIF_KSU_RESERVED_63 63
289+
#else
290+
#define TIF_KSU_MANAGED 28
291+
#define TIF_KSU_RESERVED_29 29
292+
#define TIF_KSU_RESERVED_30 30
293+
#define TIF_KSU_RESERVED_31 31
294+
#endif
295+
281296
#endif

0 commit comments

Comments
 (0)