Commit graph

2 commits

Author SHA1 Message Date
Dylan Reid
0584fe9fb2 Limit types that can be read from guest memory
Not all types are safe to read from guest memory.  Any type with a
reference or pointer will be initialized to random bits that don't refer
to a valid address.  This can cause dangling pointer and general
unsafe behavior.

To fix this, limit types that can be read with read_obj to those that
implement the unsafe trait `DataInit`.  Provide implementations of
`DataInit` for intrinsic types that are obviously safe to initialize
with random data.

Implement the needed traits for bootparam types as they are read from
the kernel image directly.

Change-Id: I1040f5bc1b2fc4c58c87d8a2ce3f618edcf6f9b1
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/540750
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-06-27 00:20:33 -07:00
Zach Reizner
00f90a4bba sys_util: add sys_util crate for misc system modules
This initial commit includes an mmap wrapper.

TEST=cargo test
BUG=None

Change-Id: I9625bd446fcd4801b2e16188897e84714b4e4ce0
Reviewed-on: https://chromium-review.googlesource.com/496987
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-05-08 12:40:50 -07:00