Safe Haskell | Unsafe |
---|---|
Language | Haskell98 |
Helper routines for exposing IO
operations on objects with
mutable labels. The mutable labels are implemented by type
MLabel
, and have an immutable meta-label (or "label label")
protecting the mutable label.
It is reasonable to allow untrusted code to modify labels by
exporting a type-restricted version of modifyMLObjLabelP
. When
this happens, asynchronous exceptions are sent to any other threads
inside mblessTCB
or mblessPTCB
if the new label revokes their
access.
- data MLObj policy l object = MLObjTCB !(MLabel policy l) !object
- mlObjTCB :: MLabelPolicyDefault policy => l -> l -> a -> LIO l (MLObj policy l a)
- mlPolicyObjTCB :: policy -> l -> l -> a -> LIO l (MLObj policy l a)
- modifyMLObjLabelP :: (PrivDesc l p, MLabelPolicy policy l) => Priv p -> MLObj policy l a -> (l -> LIO l l) -> LIO l ()
- mblessTCB :: (LabelIO l io lio, Label l) => String -> (a -> io) -> MLObj policy l a -> lio
- mblessPTCB :: (LabelIO l io lio, Label l, PrivDesc l p) => String -> (a -> io) -> Priv p -> MLObj policy l a -> lio
- data MLabel policy l = MLabelTCB {}
- newMLabelP :: PrivDesc l p => Priv p -> policy -> l -> l -> LIO l (MLabel policy l)
- labelOfMlabel :: MLabel policy l -> l
- readMLabelP :: PrivDesc l p => Priv p -> MLabel policy l -> LIO l l
- withMLabelP :: PrivDesc l p => Priv p -> MLabel policy l -> LIO l a -> LIO l a
- modifyMLabelP :: (PrivDesc l p, MLabelPolicy policy l) => Priv p -> MLabel policy l -> (l -> LIO l l) -> LIO l ()
- class MLabelOf t where
- class MLabelPolicyDefault policy where
- class MLabelPolicy policy l where
- data InternalML = InternalML
- data ExternalML = ExternalML
- class LabelIO l io lio | l io -> lio where
Objects with mutable labels
mlPolicyObjTCB :: policy -> l -> l -> a -> LIO l (MLObj policy l a) Source #
Like mlObjTCB
, but create an MLObj
with a particular policy
value. Note that you don't need to use this for ExternalML
and
InternalML
, as these don't have anything interesting in the
policy value, only the type matters. This might be useful if, for
instance, you wished to design a new policy type that embeds a
clearance.
modifyMLObjLabelP :: (PrivDesc l p, MLabelPolicy policy l) => Priv p -> MLObj policy l a -> (l -> LIO l l) -> LIO l () Source #
mblessTCB :: (LabelIO l io lio, Label l) => String -> (a -> io) -> MLObj policy l a -> lio Source #
The MLObj
equivalent of blessTCB
in
LIO.TCB.LObj. Use this for conveniently providing
LIO
versions of standard IO
functions.
mblessPTCB :: (LabelIO l io lio, Label l, PrivDesc l p) => String -> (a -> io) -> Priv p -> MLObj policy l a -> lio Source #
The MLObj
equivalent of blessPTCB
in
LIO.TCB.LObj. Use this for conveniently providing
LIO
versions of standard IO
functions.
Internal details
Mutable labels
A mutable label. Consists of a static label on the label, a
mutable label, and a list of threads currently accessing the label.
This is intended to be used by privileged code implementing IO
abstractions with mutable labels. Routines for accessing such an
IO
abstraction should perform tne IO
from within a call to
withMLabelP
, to ensure an exception is raised if another thread
revokes access with modifyMLabelP
.
newMLabelP :: PrivDesc l p => Priv p -> policy -> l -> l -> LIO l (MLabel policy l) Source #
Create an MLabel
, performing access control checks to ensure
that the labels are within the range allowed given the current
label and clearance, and the supplied privileges.
labelOfMlabel :: MLabel policy l -> l Source #
Returns the immutable label that controls access to the mutable
label value of an MLabel
.
readMLabelP :: PrivDesc l p => Priv p -> MLabel policy l -> LIO l l Source #
Retreive a snapshot of the value of a mutable label. Of course, it may already have changed by the time you process it.
withMLabelP :: PrivDesc l p => Priv p -> MLabel policy l -> LIO l a -> LIO l a Source #
Run an action that should be protected by a mutable label. An exception is thrown if the invoking thread cannot write to the mutable label given the privileges. No attempt is made to adjust the current label, even if doing so would make the permissions acceptable.
Note that if the label changes after this function has been invoked, an exception may be raised in the middle of the protected action.
modifyMLabelP :: (PrivDesc l p, MLabelPolicy policy l) => Priv p -> MLabel policy l -> (l -> LIO l l) -> LIO l () Source #
Change the mutable label in an MLabel
. Raises asynchronous
exceptions in other threads that are inside withMLabelP
if the
new label revokes their access.
MLabel modificaton policies
class MLabelPolicyDefault policy where Source #
Class for MLabelPolicy
s that don't encode any interesting
values. This allows mlObjTCB
to create an MLObj
without
requiring a policy argument.
mlabelPolicyDefault :: policy Source #
class MLabelPolicy policy l where Source #
Class of policies for when it is permissible to update an
MLabel
.
mlabelPolicy :: PrivDesc l p => policy -> p -> l -> l -> LIO l () Source #
data InternalML Source #
InternalML
is for objects contained entirely within Haskell,
such as a variable. Raising the label can't cause data to leak.
data ExternalML Source #
ExternalML
is for objects that communicate to the outside
world, where extra privileges are required since once data gets
out, so as to vouch for the fact that the other end of a socket
won't arbitrarily downgrade data.
Helper class for variadic lifting
class LabelIO l io lio | l io -> lio where Source #
Takes a
-like function and an liftIO
IO
function of an
arbitrary number of arguments (up to 10). Applies the arguments to
the IO
function, then passed the result to its argument funciton
to transform it into an LIO
function.
LabelIO l (IO r) (LIO l r) Source # | |
LabelIO l (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> IO r) (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> LIO l r) Source # | |
LabelIO l (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> IO r) (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> LIO l r) Source # | |
LabelIO l (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> IO r) (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> LIO l r) Source # | |
LabelIO l (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> IO r) (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> LIO l r) Source # | |
LabelIO l (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> IO r) (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> LIO l r) Source # | |
LabelIO l (a1 -> a2 -> a3 -> a4 -> a5 -> IO r) (a1 -> a2 -> a3 -> a4 -> a5 -> LIO l r) Source # | |
LabelIO l (a1 -> a2 -> a3 -> a4 -> IO r) (a1 -> a2 -> a3 -> a4 -> LIO l r) Source # | |
LabelIO l (a1 -> a2 -> a3 -> IO r) (a1 -> a2 -> a3 -> LIO l r) Source # | |
LabelIO l (a1 -> a2 -> IO r) (a1 -> a2 -> LIO l r) Source # | |
LabelIO l (a1 -> IO r) (a1 -> LIO l r) Source # | |