nachos.security
Class Privilege

java.lang.Object
  extended by nachos.security.Privilege

public abstract class Privilege
extends Object

A capability that allows privileged access to the Nachos machine.

Some privileged operations are guarded by the Nachos security manager:

  1. creating threads
  2. writing/deleting files in the test directory
  3. exit with specific status code
These operations can only be performed through doPrivileged().

Some privileged operations require a capability:

  1. scheduling interrupts
  2. advancing the simulated time
  3. accessing machine statistics
  4. installing a console
  5. flushing the simulated processor's pipeline
  6. approving TCB operations
These operations can be directly performed using a Privilege object.

The Nachos kernel should never be able to directly perform any of these privileged operations. If you have discovered a loophole somewhere, notify someone.


Nested Class Summary
static interface Privilege.InterruptPrivilege
          An interface that provides access to some private Interrupt methods.
static interface Privilege.MachinePrivilege
          An interface that provides access to some private Machine methods.
static interface Privilege.ProcessorPrivilege
          An interface that provides access to some private Processor methods.
static interface Privilege.TCBPrivilege
          An interface that provides access to some private TCB methods.
 
Field Summary
 Privilege.InterruptPrivilege interrupt
          Provides access to some private Interrupt methods.
 Privilege.MachinePrivilege machine
          Provides access to some private Machine methods.
 Privilege.ProcessorPrivilege processor
          Provides access to some private Processor methods.
 Stats stats
          Nachos runtime statistics.
 Privilege.TCBPrivilege tcb
          Provides access to some private TCB methods.
 
Constructor Summary
Privilege()
          Allocate a new Privilege object.
 
Method Summary
 void addExitNotificationHandler(Runnable handler)
          Add an exit() notification handler.
abstract  Object doPrivileged(PrivilegedAction action)
          Perform the specified PrivilegedAction with privilege.
abstract  Object doPrivileged(PrivilegedExceptionAction action)
          Perform the specified PrivilegedExceptionAction with privilege.
abstract  void doPrivileged(Runnable action)
          Perform the specified action with privilege.
abstract  void exit(int exitStatus)
          Exit Nachos with the specified status.
protected  void invokeExitNotificationHandlers()
          Invoke each exit() notification handler added by addExitNotificationHandler().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stats

public Stats stats
Nachos runtime statistics.


machine

public Privilege.MachinePrivilege machine
Provides access to some private Machine methods.


interrupt

public Privilege.InterruptPrivilege interrupt
Provides access to some private Interrupt methods.


processor

public Privilege.ProcessorPrivilege processor
Provides access to some private Processor methods.


tcb

public Privilege.TCBPrivilege tcb
Provides access to some private TCB methods.

Constructor Detail

Privilege

public Privilege()
Allocate a new Privilege object. Note that this object in itself does not encapsulate privileged access until the machine devices fill it in.

Method Detail

doPrivileged

public abstract void doPrivileged(Runnable action)
Perform the specified action with privilege.

Parameters:
action - the action to perform.

doPrivileged

public abstract Object doPrivileged(PrivilegedAction action)
Perform the specified PrivilegedAction with privilege.

Parameters:
action - the action to perform.
Returns:
the return value of the action.

doPrivileged

public abstract Object doPrivileged(PrivilegedExceptionAction action)
                             throws PrivilegedActionException
Perform the specified PrivilegedExceptionAction with privilege.

Parameters:
action - the action to perform.
Returns:
the return value of the action.
Throws:
PrivilegedActionException

exit

public abstract void exit(int exitStatus)
Exit Nachos with the specified status.

Parameters:
exitStatus - the exit status of the Nachos process.

addExitNotificationHandler

public void addExitNotificationHandler(Runnable handler)
Add an exit() notification handler. The handler will be invoked by exit().

Parameters:
handler - the notification handler.

invokeExitNotificationHandlers

protected void invokeExitNotificationHandlers()
Invoke each exit() notification handler added by addExitNotificationHandler(). Called by exit().