kernel: Set the tracepoint flag in a tracepoint manner
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#include "linux/compiler.h"
|
#include <linux/compiler.h>
|
||||||
#include "linux/sched/signal.h"
|
#include <linux/sched/signal.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/task_work.h>
|
#include <linux/task_work.h>
|
||||||
#include <linux/thread_info.h>
|
#include <linux/thread_info.h>
|
||||||
@@ -61,6 +61,7 @@
|
|||||||
#include "selinux/selinux.h"
|
#include "selinux/selinux.h"
|
||||||
#include "kernel_compat.h"
|
#include "kernel_compat.h"
|
||||||
#include "supercalls.h"
|
#include "supercalls.h"
|
||||||
|
#include "sucompat.h"
|
||||||
#include "sulog.h"
|
#include "sulog.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -1243,7 +1244,7 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
|
|||||||
|
|
||||||
if (new_uid.val == 2000) {
|
if (new_uid.val == 2000) {
|
||||||
if (ksu_su_compat_enabled) {
|
if (ksu_su_compat_enabled) {
|
||||||
set_tsk_thread_flag(current, TIF_SYSCALL_TRACEPOINT);
|
ksu_set_task_tracepoint_flag(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1264,7 +1265,7 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
|
|||||||
spin_lock_irq(¤t->sighand->siglock);
|
spin_lock_irq(¤t->sighand->siglock);
|
||||||
ksu_seccomp_allow_cache(current->seccomp.filter, __NR_reboot);
|
ksu_seccomp_allow_cache(current->seccomp.filter, __NR_reboot);
|
||||||
if (ksu_su_compat_enabled) {
|
if (ksu_su_compat_enabled) {
|
||||||
set_tsk_thread_flag(current, TIF_SYSCALL_TRACEPOINT);
|
ksu_set_task_tracepoint_flag(current);
|
||||||
}
|
}
|
||||||
spin_unlock_irq(¤t->sighand->siglock);
|
spin_unlock_irq(¤t->sighand->siglock);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1278,12 +1279,12 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
|
|||||||
spin_unlock_irq(¤t->sighand->siglock);
|
spin_unlock_irq(¤t->sighand->siglock);
|
||||||
}
|
}
|
||||||
if (ksu_su_compat_enabled) {
|
if (ksu_su_compat_enabled) {
|
||||||
set_tsk_thread_flag(current, TIF_SYSCALL_TRACEPOINT);
|
ksu_set_task_tracepoint_flag(current);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Disable syscall tracepoint sucompat for non-allowed processes
|
// Disable syscall tracepoint sucompat for non-allowed processes
|
||||||
if (ksu_su_compat_enabled) {
|
if (ksu_su_compat_enabled) {
|
||||||
clear_tsk_thread_flag(current, TIF_SYSCALL_TRACEPOINT);
|
ksu_clear_task_tracepoint_flag(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "ksud.h"
|
#include "ksud.h"
|
||||||
#include "kernel_compat.h"
|
#include "kernel_compat.h"
|
||||||
#include "selinux/selinux.h"
|
#include "selinux/selinux.h"
|
||||||
|
#include "sucompat.h"
|
||||||
|
|
||||||
static const char KERNEL_SU_RC[] =
|
static const char KERNEL_SU_RC[] =
|
||||||
"\n"
|
"\n"
|
||||||
@@ -83,7 +84,6 @@ void on_post_fs_data(void)
|
|||||||
done = true;
|
done = true;
|
||||||
pr_info("%s!\n", __func__);
|
pr_info("%s!\n", __func__);
|
||||||
ksu_load_allow_list();
|
ksu_load_allow_list();
|
||||||
extern void ksu_mark_running_process(void);
|
|
||||||
pr_info("mark tif for running process\n");
|
pr_info("mark tif for running process\n");
|
||||||
ksu_mark_running_process();
|
ksu_mark_running_process();
|
||||||
ksu_observer_init();
|
ksu_observer_init();
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "klog.h" // IWYU pragma: keep
|
#include "klog.h" // IWYU pragma: keep
|
||||||
#include "ksud.h"
|
#include "ksud.h"
|
||||||
#include "kernel_compat.h"
|
#include "kernel_compat.h"
|
||||||
|
#include "sucompat.h"
|
||||||
#include "sulog.h"
|
#include "sulog.h"
|
||||||
|
|
||||||
#define SU_PATH "/system/bin/su"
|
#define SU_PATH "/system/bin/su"
|
||||||
|
|||||||
26
kernel/sucompat.h
Normal file
26
kernel/sucompat.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#ifndef __KSU_H_SUCOMPAT
|
||||||
|
#define __KSU_H_SUCOMPAT
|
||||||
|
#include <linux/sched.h>
|
||||||
|
#include <linux/thread_info.h>
|
||||||
|
#include <linux/version.h>
|
||||||
|
|
||||||
|
void ksu_mark_running_process(void);
|
||||||
|
|
||||||
|
static inline void ksu_set_task_tracepoint_flag(struct task_struct *t)
|
||||||
|
{
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
|
||||||
|
set_task_syscall_work(t, SYSCALL_TRACEPOINT);
|
||||||
|
#else
|
||||||
|
set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void ksu_clear_task_tracepoint_flag(struct task_struct *t)
|
||||||
|
{
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
|
||||||
|
clear_task_syscall_work(t, SYSCALL_TRACEPOINT);
|
||||||
|
#else
|
||||||
|
clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user