From: Stefan Metzmacher Date: Fri, 8 May 2020 11:17:05 +0000 (+0200) Subject: vfs_io_uring: make use of sys_valid_io_range() in vfs_io_uring_pread_send() X-Git-Tag: ldb-2.2.0~530 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5005ae3fb24018e370ae60cc23c5e9cfe8357bc9;p=thirdparty%2Fsamba.git vfs_io_uring: make use of sys_valid_io_range() in vfs_io_uring_pread_send() 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_io_uring.c b/source3/modules/vfs_io_uring.c index 0f560c95b67..c7565b8c39d 100644 --- a/source3/modules/vfs_io_uring.c +++ b/source3/modules/vfs_io_uring.c @@ -25,6 +25,7 @@ #include "smbd/smbd.h" #include "smbd/globals.h" #include "lib/util/tevent_unix.h" +#include "lib/util/sys_rw.h" #include "smbprofile.h" #include @@ -313,6 +314,7 @@ static struct tevent_req *vfs_io_uring_pread_send(struct vfs_handle_struct *hand struct tevent_req *req = NULL; struct vfs_io_uring_pread_state *state = NULL; struct vfs_io_uring_config *config = NULL; + bool ok; SMB_VFS_HANDLE_GET_DATA(handle, config, struct vfs_io_uring_config, @@ -331,6 +333,12 @@ static struct tevent_req *vfs_io_uring_pread_send(struct vfs_handle_struct *hand 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 = (void *)data; state->iov.iov_len = n; io_uring_prep_readv(&state->ur.sqe,