virtio: video: reject resources with more than one entry

The crosvm video device cannot currently work with resources that have
more than one memory/object entry. Enforce this rule at the command
level.

BUG=b:161774071
BUG=b:169295147
TEST=Android Youtube plays properly on Hatch.

Cq-Depend: chromium:3247491
Cq-Depend: chromium:3247492
Change-Id: Ibfe2e420b4a77062cca940c5e97e7053aa4b76a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026345
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
This commit is contained in:
Alexandre Courbot 2021-06-23 18:30:29 +09:00 committed by Commit Bot
parent 5ebe30d0e5
commit 4ceec18783

View file

@ -160,6 +160,7 @@ impl<'a> VideoCmd {
planes_layout, planes_layout,
num_planes, num_planes,
plane_offsets, plane_offsets,
num_entries,
.. ..
} = r.read_obj()?; } = r.read_obj()?;
@ -181,6 +182,12 @@ impl<'a> VideoCmd {
); );
return Err(InvalidArgument); return Err(InvalidArgument);
} }
// We only support single-entry objects for now.
if num_planes != 1 || num_entries[0] != 1 {
error!("the number of entries must be equal to 1");
return Err(InvalidArgument);
}
let plane_offsets = plane_offsets[0..num_planes as usize] let plane_offsets = plane_offsets[0..num_planes as usize]
.iter() .iter()
.map(|x| Into::<u32>::into(*x)) .map(|x| Into::<u32>::into(*x))