Re: [PATCH v2 00/15] Make the user mode driver code a better citizen

From: Tetsuo Handa
Date: Tue Jun 30 2020 - 09:22:25 EST


On 2020/06/30 21:29, Eric W. Biederman wrote:
> Hmm. The wake up happens just of tgid->wait_pidfd happens just before
> release_task is called so there is a race. As it is possible to wake
> up and then go back to sleep before pid_has_task becomes false.

What is the reason we want to wait until pid_has_task() becomes false?

- wait_event(tgid->wait_pidfd, !pid_has_task(tgid, PIDTYPE_TGID));
+ while (!wait_event_timeout(tgid->wait_pidfd, !pid_has_task(tgid, PIDTYPE_TGID), 1));




By the way, commit 4a9d4b024a3102fc ("switch fput to task_work_add") says
that use of flush_delayed_fput() has to be careful. Al, is it safe to call
flush_delayed_fput() from blob_to_mnt() from umd_load_blob() (which might be
called from both kernel thread and from process context (e.g. init_module()
syscall by /sbin/insmod )) ?