vfs_io_uring: make use of sys_valid_io_range() in vfs_io_uring_pwrite_send()
authorStefan Metzmacher <metze@samba.org>
Fri, 8 May 2020 11:17:05 +0000 (13:17 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 12 May 2020 19:53:45 +0000 (19:53 +0000)
This makes the follow up commits easier as we don't have to care
about overflows.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14361

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_io_uring.c

index c7565b8c39debb3241663e775a68a30721ce0050..ee23449c63c6a89c076aa21e933250ba0b01d44b 100644 (file)
@@ -423,6 +423,7 @@ static struct tevent_req *vfs_io_uring_pwrite_send(struct vfs_handle_struct *han
        struct tevent_req *req = NULL;
        struct vfs_io_uring_pwrite_state *state = NULL;
        struct vfs_io_uring_config *config = NULL;
+       bool ok;
 
        SMB_VFS_HANDLE_GET_DATA(handle, config,
                                struct vfs_io_uring_config,
@@ -441,6 +442,12 @@ static struct tevent_req *vfs_io_uring_pwrite_send(struct vfs_handle_struct *han
                                     state->ur.profile_bytes, n);
        SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->ur.profile_bytes);
 
+       ok = sys_valid_io_range(offset, n);
+       if (!ok) {
+               tevent_req_error(req, EINVAL);
+               return tevent_req_post(req, ev);
+       }
+
        state->iov.iov_base = discard_const(data);
        state->iov.iov_len = n;
        io_uring_prep_writev(&state->ur.sqe,