lio- Labeled IO Information Flow Control Library

Safe HaskellUnsafe




This module exports the basic interface for creating and using the labeled file system, implemented as a file store. Trusted code should use initFSTCB to set the root of the labeled file system. Moreover, trusted code should implement all the IO functions in terms of createFileTCB, createDirectoryTCB, and getPathLabelTCB and setPathLabelTCB.


Initializing labeled filesystem

initFSTCB :: SLabel l => FilePath -> Maybe l -> LIO l ()Source

Initialize filesystem at the given path. The supplied path must be absolute, otherwise initFSTCB throw FSRootInvalid. If the FS has already been created then initFSTCB solely verifies that the root directory is not corrupt (see setFSTCB). Otherwise, a new FS is created with the supplied label (see mkFSTCB).

This function performs several checks that setFSTCB and mkFSTCB perform, so when considering performance they should be called directly.



:: SLabel l 
=> FilePath

Path to the filesystem root

-> l

Label of root

-> LIO l () 

Create a the file store (i.e., labeled file system) with a given label and root file path. The path must be an absolute path, otherwise initFSTCB throws FSRootInvalid.

setFSTCB :: SLabel l => FilePath -> LIO l ()Source

Set the given file path as the root of the labeled filesystem. This function throws a FSLabelCorrupt if the directory does not contain a valid label, and a FSRootCorrupt if the magicAttr attribute is missing.

getRootDirTCB :: SLabel l => LIO l FilePathSource

Get the root directory.

Handling path labels

setPathLabelTCB :: SLabel l => FilePath -> l -> LIO l ()Source

Set the label of a given path. This function sets the labelAttr attribute to the encoded label, and the hash to labelHashAttr.

getPathLabelTCB :: SLabel l => FilePath -> LIO l lSource

Get the label of a given path. If the object does not have an associated label or the hash of the label and stored-hash are not equal, this function throws FSLabelCorrupt.

Creating labeled objects

createFileTCB :: SLabel l => l -> FilePath -> IOMode -> LIO l HandleSource

Create a file object with the given label and return a handle to the new file.

createDirectoryTCB :: SLabel l => l -> FilePath -> LIO l ()Source

Create a directory object with the given label.

Labeled FilePath

data LFilePath l Source




labelOfFilePath :: l

Label of file path

unlabelFilePathTCB :: FilePath

Unlabel a filepath, ignoring IFC.

Filesystem errors

data FSError Source

Filesystem errors



Root structure is corrupt.


Root is invalid (must be absolute).


Root already exists.


Root does not exists.


Cannot create root, missing label.


FSobjectcannot be created without a label.

FSLabelCorrupt FilePath

Object label is corrupt.


Supplied file name is illegal.

Serializable label constraint

type SLabel l = (Label l, Serialize l)Source

Constraintfor serializable labels

lazyEncodeLabel :: SLabel l => l -> L8Source

Encode a label into an attribute value.

encodeLabel :: SLabel l => l -> AttrValueSource

Encode a label into an attribute value.

decodeLabel :: SLabel l => AttrValue -> Either String lSource

Descode label from an attribute value.