From 04450bfbeb7fc88b0e6ef5b1788081c66c1e1bd8 Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Wed, 26 Apr 2023 15:10:34 -0700 Subject: [PATCH] Don't return EINVAL if buf_index is set for IORING_OP_READV. This is consistent with what Linux does after bb68d504f7c4 ("io_uring: ignore ->buf_index if REQ_F_BUFFER_SELECT isn't set"). This is causing the READVWithInvalidSqeFieldValue test to fail on newer kernel. PiperOrigin-RevId: 527386953 --- pkg/sentry/fsimpl/iouringfs/iouringfs.go | 4 ---- test/syscalls/linux/io_uring.cc | 15 ++++----------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/pkg/sentry/fsimpl/iouringfs/iouringfs.go b/pkg/sentry/fsimpl/iouringfs/iouringfs.go index e294a33c7..df9108e23 100644 --- a/pkg/sentry/fsimpl/iouringfs/iouringfs.go +++ b/pkg/sentry/fsimpl/iouringfs/iouringfs.go @@ -500,10 +500,6 @@ func (fd *FileDescription) handleReadv(t *kernel.Task, sqe *linux.IOUringSqe, fl if sqe.IoPrio != 0 { return 0, linuxerr.EINVAL } - // buf_index should not be set for the READV operation. - if sqe.BufIndexOrGroup != 0 { - return 0, linuxerr.EINVAL - } // AddressSpaceActive is set to true as we are doing this from the task goroutine.And this is a // case as we currently don't support neither IOPOLL nor SQPOLL modes. diff --git a/test/syscalls/linux/io_uring.cc b/test/syscalls/linux/io_uring.cc index b793e7df4..970626c98 100644 --- a/test/syscalls/linux/io_uring.cc +++ b/test/syscalls/linux/io_uring.cc @@ -1145,12 +1145,10 @@ class IOUringSqeFieldsTest : public ::testing::Test, }; // Testing that io_uring_enter(2) successfully handles single READV operation -// and returns EINVAL error in the CQE when either ioprio or buf_index is set. -TEST_P(IOUringSqeFieldsTest, READVWithInvalidSqeFieldValue) { +// and returns EINVAL error in the CQE when ioprio is set. +TEST(IOUringTest, READVWithInvalidSqeFieldValue) { SKIP_IF(!IOUringAvailable()); - const SqeFieldsUT p = GetParam(); - IOUringParams params = {}; std::unique_ptr io_uring = ASSERT_NO_ERRNO_AND_VALUE(IOUring::InitIOUring(1, params)); @@ -1191,8 +1189,8 @@ TEST_P(IOUringSqeFieldsTest, READVWithInvalidSqeFieldValue) { sqe->len = num_blocks; sqe->off = 0; sqe->user_data = reinterpret_cast(&iov); - sqe->ioprio = p.ioprio; - sqe->buf_index = p.buf_index; + sqe->ioprio = 1; + sqe->buf_index = 0; sq_array[0] = 0; uint32_t sq_tail = io_uring->load_sq_tail(); @@ -1215,11 +1213,6 @@ TEST_P(IOUringSqeFieldsTest, READVWithInvalidSqeFieldValue) { io_uring->store_cq_head(cq_head + 1); } -INSTANTIATE_TEST_SUITE_P( - IOUringSqeFields, IOUringSqeFieldsTest, - ::testing::Values(SqeFieldsUT{.ioprio = 0, .buf_index = 1}, - SqeFieldsUT{.ioprio = 1, .buf_index = 0})); - } // namespace } // namespace testing