* Question: io_uring SQPOLL fdinfo prints host PID across pid_ns?
@ 2026-05-08 8:34 Xie Maoyi
2026-05-09 14:00 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Xie Maoyi @ 2026-05-08 8:34 UTC (permalink / raw)
To: Jens Axboe, Pavel Begunkov, io-uring@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Hi Jens, Pavel,
While testing io_uring with the SQPOLL setup flag from inside an
unprivileged user_ns + pid_ns, I noticed that
/proc/<pid>/fdinfo/<ring> prints the SQPOLL kthread's host
(init_pid_ns) PID rather than the kthread's PID as seen from the
caller's pid_ns. I'm not sure whether this is intended behaviour
or a bug worth fixing, and would appreciate your view before
sending a patch.
Reproduction (KASAN, mainline 7.0): a process unshares CLONE_NEWUSER
| CLONE_NEWPID | CLONE_NEWNS, mounts a private /proc, and a
grandchild (PID 1 in the new pid_ns) opens an io_uring ring with
IORING_SETUP_SQPOLL. Inside the new pid_ns:
/proc/self/task contains {1, 2} # SQPOLL kthread is PID 2
/proc/self/fdinfo/<ring>:
SqThread: 356 # init_pid_ns view (host PID)
After applying a candidate fix that translates sq->task_pid
through task_pid_nr_ns() against the inode's pid_ns (mirroring
pidfd_show_fdinfo() in kernel/pid.c), the same PoC prints:
SqThread: 2 # caller's pid_ns view
Is this expected behaviour, or worth fixing? If a fix would be
welcome, I have a 2+/1- patch in io_uring/fdinfo.c that's
checkpatch-clean and verified pre/post on a KASAN VM. Happy to
send the patch and the full PoC if that's useful.
Thanks,
Maoyi
________________________________
CONFIDENTIALITY: This email is intended solely for the person(s) named and may be confidential and/or privileged. If you are not the intended recipient, please delete it, notify us and do not copy, use, or disclose its contents.
Towards a sustainable earth: Print only when necessary. Thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Question: io_uring SQPOLL fdinfo prints host PID across pid_ns?
2026-05-08 8:34 Question: io_uring SQPOLL fdinfo prints host PID across pid_ns? Xie Maoyi
@ 2026-05-09 14:00 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2026-05-09 14:00 UTC (permalink / raw)
To: Xie Maoyi, Pavel Begunkov, io-uring@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
On 5/8/26 2:34 AM, Xie Maoyi wrote:
> Hi Jens, Pavel,
>
> While testing io_uring with the SQPOLL setup flag from inside an
> unprivileged user_ns + pid_ns, I noticed that
> /proc/<pid>/fdinfo/<ring> prints the SQPOLL kthread's host
> (init_pid_ns) PID rather than the kthread's PID as seen from the
> caller's pid_ns. I'm not sure whether this is intended behaviour
> or a bug worth fixing, and would appreciate your view before
> sending a patch.
>
> Reproduction (KASAN, mainline 7.0): a process unshares CLONE_NEWUSER
> | CLONE_NEWPID | CLONE_NEWNS, mounts a private /proc, and a
> grandchild (PID 1 in the new pid_ns) opens an io_uring ring with
> IORING_SETUP_SQPOLL. Inside the new pid_ns:
>
> /proc/self/task contains {1, 2} # SQPOLL kthread is PID 2
> /proc/self/fdinfo/<ring>:
> SqThread: 356 # init_pid_ns view (host PID)
>
> After applying a candidate fix that translates sq->task_pid
> through task_pid_nr_ns() against the inode's pid_ns (mirroring
> pidfd_show_fdinfo() in kernel/pid.c), the same PoC prints:
>
> SqThread: 2 # caller's pid_ns view
>
> Is this expected behaviour, or worth fixing? If a fix would be
> welcome, I have a 2+/1- patch in io_uring/fdinfo.c that's
> checkpatch-clean and verified pre/post on a KASAN VM. Happy to
> send the patch and the full PoC if that's useful.
Please send the patch, I do think we should change that.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-09 14:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08 8:34 Question: io_uring SQPOLL fdinfo prints host PID across pid_ns? Xie Maoyi
2026-05-09 14:00 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox