Re: Protection key in io uring kthread

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/23/23 8:48?PM, Jeff Xu wrote:
> Hi
> I have a question on the protection key in io_uring. Today, when a
> user thread enters the kernel through syscall, PKRU is preserved, and
> the kernel  will respect the PKEY protection of memory.
> 
> For example:
> sys_mprotect_pkey((void *)ptr, size, PROT_READ | PROT_WRITE, pkey);
> pkey_write_deny(pkey); <-- disable write access to pkey for this thread.
> ret = read(fd, ptr, 1); <-- this will fail in the kernel.
> 
> I wonder what is the case for io_uring, since read is now async, will
> kthread have the user thread's PKUR ?

There is no kthread. What can happen is that some operation may be
punted to the io-wq workers, but these act exactly like a thread created
by the original task. IOW, if normal threads retain the protection key,
so will any io-wq io_uring thread. If they don't, they do not.

> In theory, it is possible, i.e. from io_uring_enter syscall. But I
> don't know the implementation details of io_uring, hence asking the
> expert in this list.

Right, if the IO is done inline, then it won't make a difference if eg
read(2) is used or IORING_OP_READ (or similar) with io_uring.

-- 
Jens Axboe




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux