On Wed, Mar 04, 2020 at 12:09:14PM -0700, Jens Axboe wrote: > On 3/4/20 12:02 PM, Josh Triplett wrote: > > On Wed, Mar 04, 2020 at 11:00:16AM -0700, Jens Axboe wrote: > >> sqe->len can be set to a specific fd we want to use for accept4(), so > >> it uses that one instead of just assigning a free unused one. > > [...] > >> + accept->open_fd = READ_ONCE(sqe->len); > >> + if (!accept->open_fd) > >> + accept->open_fd = -1; > > > > 0 is a valid file descriptor. I realize that it seems unlikely, but I > > went to a fair bit of trouble in my patch series to ensure that > > userspace could use any valid file descriptor openat2, without a corner > > case like "you can't open as file descriptor 0", even though it would > > have been more convenient to just say "if you pass a non-zero fd in > > open_how". Please consider accepting a flag to determine the validity of > > open_fd. > > Heh, I actually just changed this, just added that as a temporary hack to > verify that things were working. Now SOCK_SPECIFIC_FD is required, and we > just gate on that. OP_ACCEPT disallowed fd != 0 before, so we continue > to do that if SOCK_SPECIFIC_FD isn't set: > > https://git.kernel.dk/cgit/linux-block/log/?h=io_uring-fd-select > > top two patches. That looks much better, thank you! For the entire 6-patch series through commit 2e4ccbb5e66eaa5963dbaf502e8adf1c063c086b: Reviewed-by: Josh Triplett <josh@xxxxxxxxxxxxxxxx>