mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
6a84706795
On systems where usize is 32 bits wide (e.g. 32-bit arm), the calculation of memory_size in bytes based on the -m configuration option in megabytes would silently overflow when the resulting value was wider than 32 bits. Change the shift that converts megabytes to bytes into a checked_mul so that a suitable error is produced if the size overflows. Additionally, change the cfg.memory type to u64 instead of usize; this is representing a size in megabytes, so its maximum value isn't related to the size of an object in memory anyway, and this avoids the need for a cast in the memory_size calculation. Requesting a memory size larger than the crosvm process can map will still result in an error at a later stage in guest startup. BUG=chromium:1028747 TEST=`crosvm run -m $((5 * 1024)) ...` on kevin Change-Id: I8fef7070bab4dafff70ed54738b26d0bb7632150 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1937551 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> |
||
---|---|---|
.. | ||
plugin | ||
argument.rs | ||
crosvm.rs | ||
linux.rs | ||
main.rs | ||
panic_hook.rs |