linux-yocto/kernel/futex
Jens Axboe aa189c3941 futex: Pass in task to futex_queue()
[ Upstream commit 5e0e02f0d7e52cfc8b1adfc778dd02181d8b47b4 ]

futex_queue() -> __futex_queue() uses 'current' as the task to store in
the struct futex_q->task field. This is fine for synchronous usage of
the futex infrastructure, but it's not always correct when used by
io_uring where the task doing the initial futex_queue() might not be
available later on. This doesn't lead to any issues currently, as the
io_uring side doesn't support PI futexes, but it does leave a
potentially dangling pointer which is never a good idea.

Have futex_queue() take a task_struct argument, and have the regular
callers pass in 'current' for that. Meanwhile io_uring can just pass in
NULL, as the task should never be used off that path. In theory
req->tctx->task could be used here, but there's no point populating it
with a task field that will never be used anyway.

Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/22484a23-542c-4003-b721-400688a0d055@kernel.dk
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-03-22 12:54:14 -07:00
..
core.c futex: Pass in task to futex_queue() 2025-03-22 12:54:14 -07:00
futex.h futex: Pass in task to futex_queue() 2025-03-22 12:54:14 -07:00
Makefile futex: Split out wait/wake 2021-10-07 13:51:11 +02:00
pi.c futex: Pass in task to futex_queue() 2025-03-22 12:54:14 -07:00
requeue.c plist: Split out plist_types.h 2023-12-20 19:26:31 -05:00
syscalls.c futex: make futex_parse_waitv() available as a helper 2023-09-29 02:37:05 -06:00
waitwake.c futex: Pass in task to futex_queue() 2025-03-22 12:54:14 -07:00