summary refs log tree commit diff
path: root/seccomp
diff options
context:
space:
mode:
authorDaniel Verkamp <dverkamp@chromium.org>2019-11-26 13:16:35 -0800
committerCommit Bot <commit-bot@chromium.org>2019-12-06 09:37:52 +0000
commit6a8470679503482a9cc794ec55c984f5564cf9f6 (patch)
tree983382d0ee0235d87fc436dbb82d39bb770774c1 /seccomp
parentbbc866e7deea7193c3ed1becbe9c5e617ca79df4 (diff)
downloadcrosvm-6a8470679503482a9cc794ec55c984f5564cf9f6.tar
crosvm-6a8470679503482a9cc794ec55c984f5564cf9f6.tar.gz
crosvm-6a8470679503482a9cc794ec55c984f5564cf9f6.tar.bz2
crosvm-6a8470679503482a9cc794ec55c984f5564cf9f6.tar.lz
crosvm-6a8470679503482a9cc794ec55c984f5564cf9f6.tar.xz
crosvm-6a8470679503482a9cc794ec55c984f5564cf9f6.tar.zst
crosvm-6a8470679503482a9cc794ec55c984f5564cf9f6.zip
linux: check memory size calculation overflow
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>
Diffstat (limited to 'seccomp')
0 files changed, 0 insertions, 0 deletions