diff --git a/upatch-manage/patch_manage.c b/upatch-manage/patch_manage.c index fa4ccf9285389eccc44ff7aecc431264a1ce8b73..0523e9d6b545d5267f721e3c8967bf2663d6faf3 100644 --- a/upatch-manage/patch_manage.c +++ b/upatch-manage/patch_manage.c @@ -164,7 +164,7 @@ static int upatch_uprobe_handler(struct uprobe_consumer *self, struct pt_regs *r goto release_out; } - spin_lock(&process->thread_lock); // ensure only one thread could check & resolve patch + mutex_lock(&process->thread_lock); // ensure only one thread could check & resolve patch /* Step 5: Process load all actived patches in target */ list_for_each_entry_safe(patch, patch_tmp, &target->actived_patches, actived_node) { @@ -191,7 +191,7 @@ static int upatch_uprobe_handler(struct uprobe_consumer *self, struct pt_regs *r log_debug("process %d: jump 0x%lx -> 0x%lx\n", tgid, pc, jump_addr); unlock_out: - spin_unlock(&process->thread_lock); + mutex_unlock(&process->thread_lock); release_out: put_process(process); diff --git a/upatch-manage/process_entity.c b/upatch-manage/process_entity.c index cf3af8223a8ccff2061871a28053652676fe6808..0b6151d1044b60923098b26ed3060832cbaba0d7 100644 --- a/upatch-manage/process_entity.c +++ b/upatch-manage/process_entity.c @@ -209,7 +209,7 @@ struct process_entity *new_process(struct task_struct *task) process->tgid = task_tgid_nr(task); process->mm = get_task_mm(task); - spin_lock_init(&process->thread_lock); + mutex_init(&process->thread_lock); INIT_HLIST_NODE(&process->node); INIT_LIST_HEAD(&process->pending_node); @@ -234,7 +234,7 @@ void release_process(struct kref *kref) process = container_of(kref, struct process_entity, kref); log_debug("free process %d\n", process->tgid); - WARN_ON(spin_is_locked(&process->thread_lock)); + WARN_ON(mutex_is_locked(&process->thread_lock)); WARN_ON(!hlist_unhashed(&process->node)); WARN_ON(!list_empty(&process->pending_node)); diff --git a/upatch-manage/process_entity.h b/upatch-manage/process_entity.h index adca78267ea96280438237c9d9c4f4f4ef65d6e2..832ba94cdcd0f4111a6d77c8eb7e3ea1f9e58ac8 100644 --- a/upatch-manage/process_entity.h +++ b/upatch-manage/process_entity.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include @@ -70,7 +70,7 @@ struct process_entity { struct mm_struct *mm; // underlying mm struct pid_t tgid; - spinlock_t thread_lock; // thread lock + struct mutex thread_lock; // thread lock struct hlist_node node; // hash table node struct list_head pending_node; // pending list node diff --git a/upatch-manage/target_entity.c b/upatch-manage/target_entity.c index e370ca8e5ca6127ab20c8398559bcc32f2dfb075..15183ec571dcfe3ef38b86b737ab7dc9aa983d3f 100644 --- a/upatch-manage/target_entity.c +++ b/upatch-manage/target_entity.c @@ -606,9 +606,9 @@ static inline void remove_patch_on_all_process(struct target_entity *target, str int bkt; hash_for_each(target->processes, bkt, process, node) { - spin_lock(&process->thread_lock); + mutex_lock(&process->thread_lock); process_remove_patch(process, patch); - spin_unlock(&process->thread_lock); + mutex_unlock(&process->thread_lock); } } @@ -939,7 +939,6 @@ struct process_entity *target_get_process(struct target_entity *target, struct t spin_unlock(&target->process_lock); out: - spin_unlock(&target->process_lock); mmput(mm); return curr_proc;