Re: [PATCH 6/6] io_uring/epoll: disallow adding an epoll file to an epoll context

Jens Axboe <[email protected]> Wed, 29 Jul 2026 04:54:22 -0600
Newsgroups org.kernel.vger.io-uring,org.kernel.vger.linux-fsdevel
Message-ID <[email protected]>
On 7/28/26 7:29 PM, Xi Ruoyao wrote:
> On Thu, 2026-05-14 at 08:07 -0600, Jens Axboe wrote:
>> One of the nastier things about epoll is how it allows adding epoll
>> files to epoll contexts. This leads to all sorts of loop detection
>> code, and has been a source of issues in the past.
>>
>> Arguably adding IORING_EPOLL_CTL is a historical mistake on the
>> io_uring side, but we're kind of stuck with it now as it does seem
>> to be in use according to code searches. But we can at least minimize
>> the damage a bit and just disallow this part of epoll, where nesting
>> issues can arise.
> 
> libuv uses this ... thing and there's even a test case against
> exercising the code path adding an epoll file:
> 
> - https://github.com/libuv/libuv/commit/3b6a1a14caee
> - https://github.com/libuv/libuv/blob/09591002d38e/test/test-poll.c#L690
> 
> And the test triggers an abort on the EINVAL at
> https://github.com/libuv/libuv/blob/09591002d38e/src/unix/linux.c#L1360

Thanks, I'll take a look.

> I'm unsure what to do here.

I think it's pretty simple - if libuv is using nesting already, then
we will have to revert this single commit before 7.2 release.

-- 
Jens Axboe