vmm: limit VSOCK CIDs to 32 bits

The VIRTIO specification[1] says:

> The upper 32 bits of the CID are reserved and zeroed.

We should therefore not allow the user to supply a VSOCK CID with
those bits set.  To accomplish this, limit the public API of the
virtio-vsock device to only accept 32-bit CIDs, while still using
64-bit CIDs internally since that's how virtio-vsock works.

[1]: https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html#x1-4400004

Signed-off-by: Alyssa Ross <hi@alyssa.is>
This commit is contained in:
Alyssa Ross
2024-01-10 16:00:54 +01:00
committed by Rob Bradford
parent 7d0b85d727
commit 451d3fb2f0
5 changed files with 15 additions and 15 deletions

View File

@@ -340,7 +340,7 @@ where
#[allow(clippy::too_many_arguments)]
pub fn new(
id: String,
cid: u64,
cid: u32,
path: PathBuf,
backend: B,
iommu: bool,
@@ -372,7 +372,7 @@ where
..Default::default()
},
id,
cid,
cid: cid.into(),
backend: Arc::new(RwLock::new(backend)),
path,
seccomp_action,