add mutex for sucompat mark

This commit is contained in:
Ylarod
2025-11-06 21:29:56 +08:00
committed by ShirkNeko
parent d416a0add7
commit bcf2a7632c

View File

@@ -1,4 +1,5 @@
#include "linux/compiler.h" #include "linux/compiler.h"
#include "linux/printk.h"
#include "selinux/selinux.h" #include "selinux/selinux.h"
#include <linux/dcache.h> #include <linux/dcache.h>
#include <linux/security.h> #include <linux/security.h>
@@ -501,9 +502,11 @@ static struct kprobe *pts_kp = NULL;
#ifdef CONFIG_KRETPROBES #ifdef CONFIG_KRETPROBES
static int tracepoint_reg_count = 0; static int tracepoint_reg_count = 0;
static DEFINE_MUTEX(tracepoint_reg_mutex);
static int syscall_regfunc_handler(struct kretprobe_instance *ri, struct pt_regs *regs) static int syscall_regfunc_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
{ {
mutex_lock(&tracepoint_reg_mutex);
if (tracepoint_reg_count < 1) { if (tracepoint_reg_count < 1) {
// while install our tracepoint, mark our processes // while install our tracepoint, mark our processes
unmark_all_process(); unmark_all_process();
@@ -513,11 +516,13 @@ static int syscall_regfunc_handler(struct kretprobe_instance *ri, struct pt_regs
mark_all_process(); mark_all_process();
} }
tracepoint_reg_count++; tracepoint_reg_count++;
mutex_unlock(&tracepoint_reg_mutex);
return 0; return 0;
} }
static int syscall_unregfunc_handler(struct kretprobe_instance *ri, struct pt_regs *regs) static int syscall_unregfunc_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
{ {
mutex_lock(&tracepoint_reg_mutex);
if (tracepoint_reg_count <= 1) { if (tracepoint_reg_count <= 1) {
// while uninstall our tracepoint, unmark all processes // while uninstall our tracepoint, unmark all processes
unmark_all_process(); unmark_all_process();
@@ -527,6 +532,7 @@ static int syscall_unregfunc_handler(struct kretprobe_instance *ri, struct pt_re
ksu_mark_running_process(); ksu_mark_running_process();
} }
tracepoint_reg_count--; tracepoint_reg_count--;
mutex_unlock(&tracepoint_reg_mutex);
return 0; return 0;
} }