For an original open-source Linux kernel, a task(taskA) may enter a blocking state(TASK_INTERRUPTIBLE/TASK_UNINTERRUPTIBLE) when running futex_wait() / running sleep() / disk IO wait / experiences a page fault interrupt and so on.
If at this time, another task run wake_up_process(taskA), without sending any signal, is this behavior safe(that is the task will not come back to user mode before futex_wake / sleep end / IO complete / page loaded)?
I have read the code for futex_wait(), yes it can handle this situation correctly:
/*
* We expect signal_pending(current), but we might be the
* victim of a spurious wakeup as well.
*/
if (!signal_pending(current))
goto retry;
https://elixir.bootlin.com/linux/v6.5.9/source/kernel/futex/waitwake.c#L668
However, I can't make sure that everywhere can handle this situation correctly, I can't read all the blocked code in kernel. Are there any constraints to ensure this security?
For example, a task run sleep(5);, then handle a signal. When it processing the signal, it blocked again, maybe TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE. At this time, the sleep time is up and will wake_up_process(task) whitout sending any signal (I guess), is this safe?