modus
Menu
On this page

The module hostile_exports

Exports that are wrong on purpose, for the tests of the callers . This module has no entry: no service holds it, and remote cannot reach it. A process loads it, or a call host runs it, and only a test does so.

What it is for. A caller must survive a callee that breaks the rules. Each export breaks one rule of the call form, and the process tables checks what the caller sees:

  • keep and kept: a lent handle ends with its call, so a later use of it gets "no handle";
  • hold and look: a mapping of a lent object ends with its call, so a later read through it faults in the process of the module, not in the caller;
  • append_past_capacity: a write past the capacity of a table reaches the caller only in a direct call, where the two share one address space;
  • mode_set and its getter mode: the palette of the console must never call a getter of a module in its own process, where a direct call has no bound. mode logs a fact, so a test sees each call of it.

The lesson: an isolated call protects the caller; a direct call trusts the module.

See: Module contract: Tables and bytes as parameters

hostile_exports module with no entry

Hash
a7a14fa6a3ca29797f571ed2c0011994ff2e68300746e1b7b0eee2b7502284b2
Size
36864 bytes
Exports
7
Imports
0
Imported by
0
License
MIT

Exports that are wrong on purpose, for the tests of the callers

FactValue
KindModules with no entry
Sourcesrc/modules/demonstrations/hostile_exports
Boot imageyes: in the boot image, 36864 bytes in this build
Build settingsnone: the defaults of the source
Importsnone
Imported bynone

Neighbours

It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.

Exports

ExportWhat it does
keep(memory: Handle(Read)) -> Integerremembers the handle that the caller lent, for a later call of kept
kept() -> Integeruses the handle that keep remembered
hold(memory: Handle(Read)) -> Integermaps a memory object that the caller lent, keeps the mapping for a later call of look, and gives the first byte
look() -> Integerreads the first byte through the mapping that hold kept
append_past_capacity(readings: Table(Reading, Append)) -> Integerwrites 4 readings after the capacity of the table, against the rule of the direction Append: a test of the caller
mode_set(mode: Mode) -> Integertakes a mode, and changes nothing: the palette shows a row of buttons for it
mode() -> Modegives the mode .slow, and logs that it ran

keep

keep(memory: (Read)) -> 

keep remembers the handle that the caller lent, for a later call of kept.

The result is the sum of the bytes of the object, read during the call. When the kernel refuses the map, the result is -1 with the error record of the kernel for the argument memory.

Parameters
  • memory: (Read)
Result
When it fails
a negative result, and the error record
Source
src/modules/demonstrations/hostile_exports/hostile_exports.odin:87

kept

kept() -> 

kept uses the handle that keep remembered. The result is the status of the kernel: 2 is "no handle", because a lent handle ends with its call.

Parameters
none
Result
Source
src/modules/demonstrations/hostile_exports/hostile_exports.odin:95

hold

hold(memory: (Read)) -> 

hold maps a memory object that the caller lent, keeps the mapping for a later call of look, and gives the first byte.

When the kernel refuses the map, the result is -1 with the error record of the kernel for the argument memory.

Parameters
  • memory: (Read)
Result
When it fails
a negative result, and the error record
Source
src/modules/demonstrations/hostile_exports/hostile_exports.odin:110

look

look() -> 

look reads the first byte through the mapping that hold kept. After an isolated call the caller revoked what it lent: the kernel removed the mapping, and the process of this module stops on a page fault.

In a direct call nothing was revoked: the mapping is still there, and the result is the first byte. With no earlier hold, the result is -1 with an error record: Absent of the mappings, for the call as a whole.

Parameters
none
Result
When it fails
a negative result, and the error record
Source
src/modules/demonstrations/hostile_exports/hostile_exports.odin:126

append_past_capacity

append_past_capacity(readings: (, Append)) -> 

append_past_capacity writes 4 readings after the capacity of the table, against the rule of the direction Append: a test of the caller. In a direct call the caller and the module share one address space, and the caller has no protection. In an isolated call the caller copies back the readings up to the capacity only.

The result is 4, and the count of the table claims 4 records more than its capacity: the caller must not believe it.

Parameters
  • readings: (, Append)
Result
Source
src/modules/demonstrations/hostile_exports/hostile_exports.odin:147

mode_set

mode_set(mode: Mode) -> 

mode_set takes a mode, and changes nothing: the palette shows a row of buttons for it.

  • mode: .slow or .fast.

The result is the value of the mode: 0 or 1, or -1 with an error record:

  • Bad_Value: the word names no mode; the record holds it.
Parameters
  • mode: Mode
Result
When it fails
a negative result, and the error record
Source
src/modules/demonstrations/hostile_exports/hostile_exports.odin:175

mode

mode() -> Mode

mode gives the mode .slow, and logs that it ran.

A console that loaded this module in its own process must never call it from the palette: a getter that loops there would hold the console for good.

Parameters
none
Result
Mode
Source
src/modules/demonstrations/hostile_exports/hostile_exports.odin:190

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

Handle wire form

A wire form of the module contract: one word of a call. A handle that the caller lends for the time of the call, in a register.

Integer wire form

A wire form of the module contract: one word of a call. A signed integer of 64 bits, in a register.

Error_Record record of a module

A record of the module hostile_exports: 56 bytes, aligned on 8 bytes, 0 bytes of padding.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

Table wire form

A wire form of the module contract: one word of a call. Records of one description that follow each other (a table).

Reading record of a module

A record of the module hostile_exports: 40 bytes, aligned on 8 bytes, 0 bytes of padding.

  • sensori6408 bytes
  • timei6488 bytes
  • valuei64168 bytes
  • minimumi64248 bytes
  • maximumi64328 bytes