Skip to contentSkip to conversation

io_uring/sync: validate passed in offset

PATCH New Jens Axboe 1 participant 1 message Jan 21 io_uring

lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 io_uring/sync: validate passed in offset

Check if the passed in offset is negative once cast to sync->off. This ensures that -EINVAL is returned for that case, like it would be for sync_file_range(2).

Fixes c992fe2925d7 ("io_uring: add fsync support")

---

io_uring/sync.c +2 -0
index cea2d381ffd2..ab7fa1cd7dd6 100644
@@ -62,6 +62,8 @@ int io_fsync_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 		return -EINVAL;
 
 	sync->off = READ_ONCE(sqe->off);
+	if (sync->off < 0)
+		return -EINVAL;
 	sync->len = READ_ONCE(sqe->len);
 	req->flags |= REQ_F_FORCE_ASYNC;
 	return 0;
Signature · 1 line
Jens Axboe