summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergio Lopez <slp@redhat.com>2020-03-16 12:52:25 +0100
committerAndreea Florescu <andreea.florescu15@gmail.com>2020-09-04 17:59:53 +0300
commit6a33fb176aaf691faaa75d9fa47a0ef6c9a697f0 (patch)
tree59e20dbb2fbdccba31147b00fae26510b3ad0d46 /src
parent791de4996372270ae88e6303bb5664f0c886b3f8 (diff)
downloadvmm_vhost-6a33fb176aaf691faaa75d9fa47a0ef6c9a697f0.tar.gz
vhost-user: Fix VhostUserConfig validation
The offset field in the VhostUserConfig message is used to indicate that the data included in the payload comes from that offset within the virtio configuration space. This used in SET_CONFIG messages to send partial updates. For example to update the WCE field in VirtioBlockConfig, only a single byte payload is needed. It has no relationship with the actual disposition of the configuration space in the device memory, so don't check that in the validation. Signed-off-by: Sergio Lopez <slp@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/vhost_user/message.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/vhost_user/message.rs b/src/vhost_user/message.rs
index ccaa6b8..5d4467e 100644
--- a/src/vhost_user/message.rs
+++ b/src/vhost_user/message.rs
@@ -584,11 +584,9 @@ impl VhostUserMsgValidator for VhostUserConfig {
fn is_valid(&self) -> bool {
if (self.flags & !VhostUserConfigFlags::all().bits()) != 0 {
return false;
- } else if self.offset < VHOST_USER_CONFIG_OFFSET
- || self.offset >= VHOST_USER_CONFIG_SIZE
- || self.size == 0
- || self.size > (VHOST_USER_CONFIG_SIZE - VHOST_USER_CONFIG_OFFSET)
- || self.size + self.offset > VHOST_USER_CONFIG_SIZE
+ } else if self.size == 0
+ || self.size > VHOST_USER_CONFIG_SIZE
+ || self.size + self.offset >= VHOST_USER_CONFIG_SIZE
{
return false;
}