diff options
author | Zach Reizner <zachr@google.com> | 2019-02-13 17:33:32 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-02-28 03:24:24 -0800 |
commit | a60744b42ee2589e9318029cf3fd7d87fd73f29d (patch) | |
tree | 4819c7b24caab92956d95474e638eb067a5ce926 /devices/src/proxy.rs | |
parent | b7196e2a1c1eb7123e7eace5418b7eb4a3e24dbe (diff) | |
download | crosvm-a60744b42ee2589e9318029cf3fd7d87fd73f29d.tar crosvm-a60744b42ee2589e9318029cf3fd7d87fd73f29d.tar.gz crosvm-a60744b42ee2589e9318029cf3fd7d87fd73f29d.tar.bz2 crosvm-a60744b42ee2589e9318029cf3fd7d87fd73f29d.tar.lz crosvm-a60744b42ee2589e9318029cf3fd7d87fd73f29d.tar.xz crosvm-a60744b42ee2589e9318029cf3fd7d87fd73f29d.tar.zst crosvm-a60744b42ee2589e9318029cf3fd7d87fd73f29d.zip |
crosvm: use seqpacket rather than datagram sockets
The advantage of seqpacket is that they are connection oriented. A listener can be created that accepts new connections, useful for the path based VM control sockets. Previously, the only bidirectional sockets in crosvm were either stream based or made using socketpair. This change also whitelists sendmsg and recvmsg for the common device policy. TEST=cargo test BUG=chromium:848187 Change-Id: I83fd46f54bce105a7730632cd013b5e7047db22b Reviewed-on: https://chromium-review.googlesource.com/1470917 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'devices/src/proxy.rs')
-rw-r--r-- | devices/src/proxy.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/devices/src/proxy.rs b/devices/src/proxy.rs index 4bc3405..a91d2ed 100644 --- a/devices/src/proxy.rs +++ b/devices/src/proxy.rs @@ -7,14 +7,14 @@ use libc::pid_t; use std::os::unix::io::{AsRawFd, RawFd}; -use std::os::unix::net::UnixDatagram; use std::process; use std::time::Duration; use std::{self, fmt, io}; +use io_jail::{self, Minijail}; use msg_socket::{MsgOnSocket, MsgReceiver, MsgSender, MsgSocket}; +use sys_util::net::UnixSeqpacket; -use io_jail::{self, Minijail}; use BusDevice; /// Errors for proxy devices. @@ -64,7 +64,7 @@ enum CommandResult { ReadConfigResult(u32), } -fn child_proc(sock: UnixDatagram, device: &mut BusDevice) { +fn child_proc(sock: UnixSeqpacket, device: &mut BusDevice) { let mut running = true; let sock = MsgSocket::<CommandResult, Command>::new(sock); @@ -138,7 +138,7 @@ impl ProxyDevice { mut keep_fds: Vec<RawFd>, ) -> Result<ProxyDevice> { let debug_label = device.debug_label(); - let (child_sock, parent_sock) = UnixDatagram::pair().map_err(Error::Io)?; + let (child_sock, parent_sock) = UnixSeqpacket::pair().map_err(Error::Io)?; keep_fds.push(child_sock.as_raw_fd()); // Forking here is safe as long as the program is still single threaded. |