vmsilo fork of vhost rust libraries
Find a file
Alyssa Ross 0152e88b42 vhost_user: fix UB on invalid master request
Since VhostUserMsgHeader implements ByteValued, it is supposed to be
safe to construct from any correctly-sized arbitrary byte array.
But that means we can do this:

	let bytes = b"\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00";
	let header = VhostUserMsgHeader::<MasterReq>::from_slice(bytes).unwrap();
	header.get_code()

constructing an invalid MasterReq, using only functions that are
marked as safe.  Constructing an invalid enum value is undefined
behavior in Rust, so this API is unsound.  This wasn't considered by
the safety comment in VhostUserMsgHeader::get_code, which only
considered the safety of requests that were valid enum variants.

If the vhost-user frontend process sends a message that the backend
doesn't recognise, that's exactly what will happen, so the UB can be
triggered from an external process (but a trusted one).

To fix this, we need to check whether the value is valid _before_
converting it.  Req::is_valid is changed to be a non-instance method,
so it can be called before constructing the Req.
VhostUserMsgHeader::get_code is changed to return a Result, to
accomodate the case where the request number is not a valid value for
R.

Signed-off-by: Alyssa Ross <alyssa.ross@unikie.com>
2023-01-02 15:13:49 +01:00
.buildkite Deprecate custom pipeline 2021-09-03 10:16:46 +03:00
.cargo fix link issues on aarch64 musl 2020-09-04 17:59:53 +03:00
.github update dependabot formatting 2021-09-10 17:24:49 +03:00
crates vhost_user: fix UB on invalid master request 2023-01-02 15:13:49 +01:00
rust-vmm-ci@99fe2eb2e0 build(deps): bump rust-vmm-ci from 99fe2eb to 5f36cc9 2022-09-20 16:04:12 +02:00
.gitignore Update .gitignore file 2021-03-01 12:50:56 +01:00
.gitmodules Switch to rust-vmm-ci for the CI 2020-09-04 17:59:53 +03:00
Cargo.toml Merge remote-tracking branch 'vhost-user-backend/main' into workspace 2022-10-11 12:27:44 +05:30
CODEOWNERS fix CODEOWNERS file 2022-02-16 15:55:50 +01:00
coverage_config_aarch64.json Convert to a workspace 2022-10-11 11:59:25 +05:30
coverage_config_x86_64.json Merge remote-tracking branch 'vhost-user-backend/main' into workspace 2022-10-11 12:27:44 +05:30
LICENSE Initial commit 2019-04-03 14:38:29 +08:00
LICENSE-BSD-3-Clause Refine BSD-3-Clause license file 2021-11-26 21:19:40 +08:00
README.md vhost: Add README for the workspace 2022-10-11 12:28:33 +05:30

vhost

The vhost workspace hosts libraries related to the vhost and vhost-user protocols. It currently consists of the following crates:

  • vhost -> A pure rust library for vDPA, vhost and vhost-user.
  • vhost-user-backend -> It provides a framework to implement vhost-user backend services.