Make VhostUserMsgValidator use ByteValued
`extract_request_body()` assumes these types are POD as a safety invariant, which is only possible if `VhostUserMsgValidator` is itself an `unsafe trait` or depends on an `unsafe trait` with the correct invariants. `VhostUserMemoryRegion` is the only type that implemented `VhostUserMsgValidator` and did not yet implement `ByteValued` Signed-off-by: Manish Goregaokar <manishsmail@gmail.com>
This commit is contained in:
parent
6ca88e160a
commit
10bf1e9123
1 changed files with 4 additions and 1 deletions
|
|
@ -203,7 +203,7 @@ impl Req for SlaveReq {
|
|||
}
|
||||
|
||||
/// Vhost message Validator.
|
||||
pub trait VhostUserMsgValidator {
|
||||
pub trait VhostUserMsgValidator: ByteValued {
|
||||
/// Validate message syntax only.
|
||||
/// It doesn't validate message semantics such as protocol version number and dependency
|
||||
/// on feature flags etc.
|
||||
|
|
@ -594,6 +594,9 @@ impl VhostUserMemoryRegion {
|
|||
}
|
||||
}
|
||||
|
||||
// SAFETY: Safe because all fields of VhostUserMemoryRegion are POD.
|
||||
unsafe impl ByteValued for VhostUserMemoryRegion {}
|
||||
|
||||
impl VhostUserMsgValidator for VhostUserMemoryRegion {
|
||||
fn is_valid(&self) -> bool {
|
||||
self.is_valid()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue