ish-app / ish

Linux shell for iOS
https://ish.app
Other
16.34k stars 856 forks source link

fix locking pids_lock timing of do_exit #2300

Open ShoichiroKitano opened 6 months ago

ShoichiroKitano commented 6 months ago

I have corrected the timing of locking the pids_lock in the do_exit function to be before mm_release.

The reason for this fix is that there was a potential for invalid memory access when executing processes related to /proc/{pid}, specifically when memory for the struct task member is freed during the process (this issue occurred during the execution of tmux). Additionally, there was a problem where resources locked during operations on /proc/{pid} were being released in do_exit, leading to further issues, so I addressed and fixed that as well.

tbodt commented 6 months ago

Unfortunately this violates the lock ordering of always taking a task group lock after taking pids_lock.

ShoichiroKitano commented 6 months ago

@tbodt I'm sorry. Since I can't understand the issue, could you provide a bit more information? To the best of my understanding, in this fix, it appears that the lock on group->lock will be acquired after acquiring the lock on pids_lock.