Crate cloudabi

source ·
Expand description

PLEASE NOTE: This entire crate including this documentation is automatically generated from cloudabi.txt

Nuxi CloudABI

CloudABI is what you get if you take POSIX, add capability-based security, and remove everything that’s incompatible with that. The result is a minimal ABI consisting of only 49 syscalls.

CloudABI doesn’t have its own kernel, but instead is implemented in existing kernels: FreeBSD has CloudABI support for x86-64 and arm64, and a patch-set for NetBSD and a patch-set for Linux are available as well. This means that CloudABI binaries can be executed on different operating systems, without any modification.

Capability-Based Security

Capability-based security means that processes can only perform actions that have no global impact. Processes cannot open files by their absolute path, cannot open network connections, and cannot observe global system state such as the process table.

The capabilities of a process are fully determined by its set of open file descriptors (fds). For example, files can only be opened if the process already has a file descriptor to a directory the file is in.

Unlike in POSIX, where processes are normally started with file descriptors 0, 1, and 2 reserved for standard input, output, and error, CloudABI does not reserve any file descriptor numbers for specific purposes.

In CloudABI, a process depends on its parent process to launch it with the right set of resources, since the process will not be able to open any new resources. For example, a simple static web server would need to be started with a file descriptor to a TCP listener, and a file descriptor to the directory for which to serve files. The web server will then be unable to do anything other than reading files in that directory, and process incoming network connections.

So, unknown CloudABI binaries can safely be executed without the need for containers, virtual machines, or other sandboxing technologies.

Watch Ed Schouten’s Talk at 32C3 for more information about what capability-based security for UNIX means.

Cloudlibc

Cloudlibc is an implementation of the C standard library, without all CloudABI-incompatible functions. For example, Cloudlibc does not have printf, but does have fprintf. It does not have open, but does have openat.

CloudABI-Ports

CloudABI-Ports is a collection of ports of commonly used libraries and applications to CloudABI. It contains software such as zlib, libpng, boost, memcached, and much more. The software is patched to not depend on any global state, such as files in /etc or /dev, using open(), etc.

Using CloudABI

Instructions for using CloudABI (including kernel modules/patches, toolchain, and ports) are available for several operating systems:

Specification of the ABI

The entire ABI is specified in a a file called cloudabi.txt, from which all headers and documentation (including the one you’re reading now) is generated.

Structs

Auxiliary vector entry.
A region of memory for scatter/gather writes.
A userspace condition variable.
Identifier for a device containing a file system. Can be used in combination with inode to uniquely identify a file on the local system.
A reference to the offset of a directory entry.
A directory entry.
An event that occurred.
The state of the file descriptor subscribed to with FD_READ or FD_WRITE.
A file descriptor number.
File descriptor flags.
Which file descriptor attributes to adjust.
File descriptor attributes.
File attributes.
Which file attributes to adjust.
File serial number that is unique within its file system.
A region of memory for scatter/gather reads.
A userspace read-recursive readers-writer lock, similar to a Linux futex or a FreeBSD umtx.
Path lookup properties.
Flags determining the method of how paths are resolved.
Memory mapping flags.
Memory page protection options.
Methods of synchronizing memory with physical storage.
Open flags used by file_open().
Arguments of sock_recv().
Flags provided to sock_recv().
File descriptor rights, determining which actions may be performed.
Flags returned by sock_recv().
Which channels on a socket need to be shut down.
Arguments of sock_send().
Flags provided to sock_send(). As there are currently no flags defined, it must be set to zero.
Flags determining how the timestamp provided in subscription.union.clock.timeout should be interpreted.
Flags influencing the method of polling for read or writing on a file descriptor.
Subscription to an event.
The Thread Control Block (TCB).
Attributes for thread creation.
Unique system-local identifier of a thread. This identifier is only valid during the lifetime of the thread.
Specifies whether files are unlinked or directories are removed.

Enums

File or memory access pattern advisory information.
Enumeration describing the kind of value stored in auxv.
Identifiers for clocks.
Error codes returned by system calls.
Type of a subscription to an event or its occurrence.
The type of a file descriptor or file.
Indicates whether an object is stored in private or shared memory.
Signal condition.
Relative to which position the offset of the file descriptor should be set.

Constants

The condition variable is in its initial state. There are no threads waiting to be woken up. If the condition variable has any other value, the kernel must be called to wake up any sleeping threads.
Permanent reference to the first directory entry within a directory.
Value indicating that the lock is in an incorrect state. A lock cannot be in its initial unlocked state, while also managed by the kernel.
Bitmask indicating that the lock is either read locked or write locked, and that one or more threads have their execution suspended, waiting to acquire the lock. The last owner of the lock must call the kernel to unlock.
Value indicating that the lock is in its initial unlocked state.
Bitmask indicating that the lock is write-locked. If set, the lower 30 bits of the lock contain the identifier of the thread that owns the write lock. Otherwise, the lower 30 bits of the lock contain the number of acquired read locks.
Passed to mem_map() when creating a mapping to anonymous memory.
Returned to the child process by proc_fork().

Functions

Obtains the resolution of a clock.
Obtains the time value of a clock.
Wakes up threads waiting on a userspace condition variable.
Closes a file descriptor.
Creates a file descriptor.
Creates a pair of file descriptors.
Synchronizes the data of a file to disk.
Duplicates a file descriptor.
Reads from a file descriptor, without using and updating the file descriptor’s offset.
Writes to a file descriptor, without using and updating the file descriptor’s offset.
Reads from a file descriptor.
Atomically replaces a file descriptor by a copy of another file descriptor.
Moves the offset of the file descriptor.
Gets attributes of a file descriptor.
Adjusts attributes of a file descriptor.
Synchronizes the data and metadata of a file to disk.
Writes to a file descriptor.
Provides file advisory information on a file descriptor.
Forces the allocation of space in a file.
Creates a file of a specified type.
Creates a hard link.
Opens a file.
Reads directory entries from a directory.
Reads the contents of a symbolic link.
Renames a file.
Gets attributes of a file by file descriptor.
Adjusts attributes of a file by file descriptor.
Gets attributes of a file by path.
Adjusts attributes of a file by path.
Creates a symbolic link.
Unlinks a file, or removes a directory.
Unlocks a write-locked userspace lock.
Provides memory advisory information on a region of memory.
Creates a memory mapping, making the contents of a file accessible through memory.
Change the protection of a memory mapping.
Synchronize a region of memory with its physical storage.
Unmaps a region of memory.
poll
Concurrently polls for the occurrence of a set of events.
Replaces the process by a new executable.
Terminates the process normally.
Forks the process of the calling thread.
Sends a signal to the process of the calling thread.
Obtains random data from the kernel random number generator.
Receives a message on a socket.
Sends a message on a socket.
Shuts down socket send and receive channels.
Creates a new thread within the current process.
Terminates the calling thread.
Temporarily yields execution of the calling thread.

Type Definitions

Exit code generated by a process when exiting.
Relative offset within a file.
Non-negative file size or length of a region within a file.
Number of hard links to an inode.
Specifies the number of threads sleeping on a condition variable that should be woken up.
Entry point for a process (_start).
Entry point for additionally created threads.
Timestamp in nanoseconds.
User-provided value that can be attached to objects that is retained when extracted from the kernel.

Unions

A union inside auxv.
A union inside event.
A union inside subscription.