crosvm/rutabaga_gfx
Gurchetan Singh 6c219468aa rutabaga_gfx/ffi: fix case when num_in_fences or cmd_size is zero
Following observed:

thread '<unnamed>' panicked at library/core/src/panicking.rs:156:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
stack backtrace:
  20:     0x7fbc13444397 - rutabaga_ffi::rutabaga_submit_command::{{closure}}::h396fa3925e07701c
  21:     0x7fbc1342af28 - core::ops::function::FnOnce::call_once::h83bf6f55aff2e840
  22:     0x7fbc13423a36 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h988a1c0089589129
  23:     0x7fbc134292a8 - std::panicking::try::do_call::h83aa5cffd0c7a46a
  24:     0x7fbc13444eeb - __rust_try
  25:     0x7fbc13428c13 - std::panicking::try::hc36d232483e714b8
  26:     0x7fbc13427c7d - std::panic::catch_unwind::h2433ece368f25877
  27:     0x7fbc134442f0 - rutabaga_submit_command

Reason, according to the docs:

"data must be non-null and aligned even for
 zero-length slices."

Add check to prevent hitting this case.

BUG=none
TEST=compile

Change-Id: Ic0d36055a13cd1cc9c65e7e12c0aef7aa95a58ce
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5718431
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2024-07-17 22:58:42 +00:00
..
ffi rutabaga_gfx/ffi: fix case when num_in_fences or cmd_size is zero 2024-07-17 22:58:42 +00:00
kumquat rutabaga_gfx: kumquat: support GPU mappings 2024-07-11 23:06:07 +00:00
src rutabaga_gfx: cross_domain: fix bug in channel reporting 2024-07-17 21:25:35 +00:00
build.rs rutabaga_gfx: hook up FFI snapshot to gfxstream 2024-02-13 19:06:13 +00:00
Cargo.toml rutabaga_gfx: introduce virtgpu_kumquat + Kumquat server 2024-07-01 21:41:01 +00:00
LICENSE crosvm: add licensing/description to alpha crates 2023-01-14 02:05:06 +00:00
OWNERS rutabaga_gfx: establish crate OWNERS. 2024-05-14 17:44:27 +00:00