diff --git a/kernel/allowlist.c b/kernel/allowlist.c index f809c529..b7a15143 100644 --- a/kernel/allowlist.c +++ b/kernel/allowlist.c @@ -1,3 +1,5 @@ +#include +#include #include #include #include @@ -357,7 +359,7 @@ bool ksu_get_allow_list(int *array, int *length, bool allow) return true; } -void persistent_allow_list() +static void do_persistent_allow_list(struct callback_head *_cb) { u32 magic = FILE_MAGIC; u32 version = FILE_FORMAT_VERSION; @@ -365,6 +367,7 @@ void persistent_allow_list() struct list_head *pos = NULL; loff_t off = 0; + mutex_lock(&allowlist_mutex); struct file *fp = filp_open(KERNEL_SU_ALLOWLIST, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (IS_ERR(fp)) { @@ -393,6 +396,29 @@ void persistent_allow_list() exit: filp_close(fp, 0); + mutex_unlock(&allowlist_mutex); +} + +void persistent_allow_list() +{ + struct task_struct *tsk; + + tsk = get_pid_task(find_vpid(1), PIDTYPE_PID); + if (!tsk) { + pr_err("save_allow_list find init task err\n"); + return; + } + + struct callback_head *cb = + kzalloc(sizeof(struct callback_head), GFP_KERNEL); + if (!cb) { + pr_err("save_allow_list alloc cb err\b"); + return; + } + cb->func = do_persistent_allow_list; + task_work_add(tsk, cb, TWA_RESUME); + + put_task_struct(tsk); } void ksu_load_allow_list()