From 33be24bd5a6eb6e4c4951abfe815f06de6610b6a Mon Sep 17 00:00:00 2001 From: Eryu Guan Date: Fri, 27 Mar 2020 17:35:55 +0800 Subject: [PATCH] vhost-user-fs: return EINVAL if req is out of range in fs_slave_mmap/unmap/sync Return libc::EINVAL instead of custom "Wrong offset" error, as mmap(2) returns EINVAL when offset/len is invalid. Signed-off-by: Eryu Guan --- vm-virtio/src/vhost_user/fs.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vm-virtio/src/vhost_user/fs.rs b/vm-virtio/src/vhost_user/fs.rs index 9c7700c01..c479dc7b5 100644 --- a/vm-virtio/src/vhost_user/fs.rs +++ b/vm-virtio/src/vhost_user/fs.rs @@ -71,7 +71,7 @@ impl VhostUserMasterReqHandler for SlaveReqHandler { } if !self.is_req_valid(offset, len) { - return Err(io::Error::new(io::ErrorKind::Other, "Wrong offset")); + return Err(io::Error::from_raw_os_error(libc::EINVAL)); } let addr = self.mmap_cache_addr + offset; @@ -117,7 +117,7 @@ impl VhostUserMasterReqHandler for SlaveReqHandler { } if !self.is_req_valid(offset, len) { - return Err(io::Error::new(io::ErrorKind::Other, "Wrong offset")); + return Err(io::Error::from_raw_os_error(libc::EINVAL)); } let addr = self.mmap_cache_addr + offset; @@ -152,7 +152,7 @@ impl VhostUserMasterReqHandler for SlaveReqHandler { } if !self.is_req_valid(offset, len) { - return Err(io::Error::new(io::ErrorKind::Other, "Wrong offset")); + return Err(io::Error::from_raw_os_error(libc::EINVAL)); } let addr = self.mmap_cache_addr + offset;