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
This commit is contained in:
Ayush Ranjan
2023-04-26 15:13:33 -07:00
committed by gVisor bot
parent 96f2aca71f
commit 04450bfbeb
2 changed files with 4 additions and 15 deletions
-4
View File
@@ -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.
+4 -11
View File
@@ -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<IOUring> 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<uint64_t>(&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