devices: Deduplicate mapped file descriptors.

A bugfix to minijail made the logic more strict so deduplicate the
mapping requests before giving them to libminijail.

BUG=b:2591867,chromium:1198756
TEST=CQ passes

Change-Id: Ide397e9aa82b493418d8ac4e51a73af649295424
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2851078
Tested-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Allen Webb <allenwebb@google.com>
This commit is contained in:
Allen Webb 2021-04-26 09:54:27 -05:00 committed by Commit Bot
parent a88cb19890
commit e6c584a6aa

View file

@ -150,6 +150,11 @@ impl ProxyDevice {
let (child_tube, parent_tube) = Tube::pair().map_err(Error::Tube)?;
keep_rds.push(child_tube.as_raw_descriptor());
// Deduplicate the FDs since minijail expects this.
keep_rds.sort_unstable();
keep_rds.dedup();
// Forking here is safe as long as the program is still single threaded.
let pid = unsafe {
match jail.fork(Some(&keep_rds)).map_err(Error::ForkingJail)? {