Skip to content

Interface

Nicholas Renner edited this page Jun 30, 2021 · 10 revisions

SafePOSIX - Rust Interface

One element of our security model is to contain our kernel calls to the "popular paths". To ensure this, SafePOSIX-Rust must only call to libraries (via the Rust standard libraries, and any crates) via paths that limit kernel calls to these popular paths.

The SafePOSIX-Rust interface exposes SafePOSIX to these libraries in four files:

  1. file.rs - filesystem related calls
  2. comm.rs - network related calls
  3. timer.rs - time related calls
  4. misc.rs - locks, serialization, etc.

These files make up our interface module, and are the only place libraries are imported via use. This allows us to fuzz this slimmer interface for kernel access to ensure the broader SafePOSIX code can only access the popular paths.

SafePOSIX is then built using this interface. No library imports via use are allowed in any of the files that implement SafePOSIX. Any attempts to import outside libraries will be rejected via code review.

File

File.rs includes the following interface functions:

OPEN_FILES - a global locked hash-set of open files

EmulatedFile - a struct that includes: the filename (String), the filepath, the file object (Rust File w/ Lock), and the filesize (usize), it includes the following methods:

  • new - Constructor
  • close - Safely closes the emulated file
  • readat - reads a file from offset location to a C-buffer
  • writeat - writes from a C-buffer to a file at given offset
  • readfile_to_new_string - reads entire file to new Rust String (used to restore metadata)
  • writefile_from_string - writes to entire file from Rust String (used for metadata persistence)
  • zerofill_at - writes a specified number of 0's to file
  • as_fd_handle_raw_int - gets system fd number of open file

Clone this wiki locally