Setting
A sensor gateway is a small device that collects readings from sensors and passes them on. In this invented example the gateway also accepts a small decision program, delivered through a phone from a publisher, the one party authorized to change the gateway’s rules. The gateway’s own software, the host, runs the decision program, the guest, inside a virtual machine §2.3 (VM), a part of the host that carries out the guest’s instructions one at a time. For every management request, a request to change one of the gateway’s settings, the host runs the guest, which answers ALLOW or DENY. Meanwhile the gateway keeps sampling its sensors and handling radio traffic.
It has been established that the guest cannot read or write memory outside the regions the host gave it. To stop endless loops, the VM gives each run an instruction budget §2.32, also called fuel, of 1000 guest instructions and stops the run when the budget is used up. The guest may call helper functions §2.19, host routines offered to it, and the slowest helper takes up to 300 microseconds. Suppose an attacker has got a malicious guest accepted, or the publisher has shipped a harmful one. The question is whether a guest that cannot corrupt memory can still deny service.
Short answer
Yes. Memory safety limits where the guest reads and writes, not how much it consumes or what it decides. A confined guest can spend its whole budget on every run, call slow helpers, start work that outlives the run, fill host queues, or answer DENY to every request. Each of these is a denial of service §1.28: the device stops being useful to its legitimate users. Each resource needs its own limit and accounting, and the owner needs a way to override the guest’s decisions.
Follow-up questions
First answer
Yes. Memory safety, the guarantee that a downloaded program, the guest, never touches memory outside the regions it was given, says nothing about the resources the guest uses or the decisions it makes. A confined guest can still:
use processor time, by running its full instruction budget on every request, which leaves less time for the device’s other work;
use time inside helper functions, routines of the device’s own software that the guest may call, each of which can cost far more than one instruction;
start work that outlives the run, such as radio messages that a helper queues for sending, which take queue memory and radio airtime §18.2.19 after the guest has finished;
wear out storage, through a helper that writes to flash memory §6.6 on every run, since each flash block survives only a limited number of erase cycles;
decide badly, by answering
DENYto every request to change a setting. Such a run ends after about 1 microsecond and uses almost nothing, yet the owner can no longer manage the device.
Each of these is a denial of service, a loss of availability §1.10. Each resource needs its own limit, charged on every path that uses it, which is complete mediation §1.16 applied to resources. The last case needs a recovery authority §1.46 as well: a way, not subject to the guest’s own verdict, for the owner or publisher to replace the guest.
Does fuel solve it?
No. Fuel bounds one quantity, the number of guest instructions in one run, and denial of service has other sources. Fuel, also called an instruction budget, is a counter that the virtual machine (VM) running a downloaded program, the guest, decreases for every guest instruction it executes; at zero the VM stops the run. If every path that executes guest instructions decreases the counter, including backward jumps and calls between the guest’s own functions, then a run executes at most the budget, say 1000 instructions. That guarantees that the guest’s own instructions cannot keep a run going forever. It does not bound:
Time inside helpers. A call to a helper function, a host routine the guest may call, is charged as one instruction but may run for 300 microseconds, or wait for a radio reply that never comes. While the helper waits, no guest instruction runs, so the counter does not move and fuel never stops it.
Work that outlives the run, such as messages queued for the radio or flash writes started by a helper.
Waiting for other activities, such as a lock held by another thread (an independently scheduled sequence of execution), or interrupts §6.11, hardware signals that make the processor run a handler instead of the guest.
Repetition. The budget applies per run. An attacker who can trigger runs at will multiplies it by the number of runs.
Turning fuel into a time bound needs more: a maximum time per instruction, a bound on each helper’s running time with no unlimited waits, limits on work that continues after the run, and a model of scheduling and interference.
Write a conditional time bound
A conditional time bound is an upper limit on running time that holds only when named assumptions hold. Take one run of a downloaded program, the guest, inside a virtual machine (VM), from the moment the VM starts the guest until the guest’s verdict is returned. Define:
: the largest number of charged steps, guest instructions counted against the instruction budget, that one run can execute; with a budget of 1000, .
: the longest time one charged step can take on this processor, not counting the body of a helper function; here microseconds.
: the largest number of helper calls one run can make; here .
: the longest time one helper body can take, which requires that the helper never waits without limit; here microseconds.
: fixed work per run, such as preparing and clearing guest memory; here microseconds.
: the most time that other work can take from the processor during the run. That work is interrupt handlers §6.12, which hardware signals start at any moment, and threads of higher priority, sequences of execution that the scheduler runs in preference to the thread that runs the guest; here microseconds.
If these parts do not overlap, so that no time is counted twice, the run time satisfies With the values above, microseconds and microseconds, so microseconds, which is 3.2 milliseconds.
This is a bound derived from assumptions, not a measured time, and each term needs its own justification. must cover the slowest instruction, such as a division, including any time the processor waits for memory. must be enforced, for example by limiting the number of helper calls per run. needs an analysis of each helper. needs a bound on how often each interrupt and each higher-priority thread can arrive and how long each takes. A longer run lets more interference arrive, so must be computed for a time window at least as long as the resulting ; fixed-priority response-time analysis §19.4.7 does this by recomputing the bound until its value stops changing.
Why can pacing help and still fail a deadline?
Pacing caps the share of the processor that a kind of work can take, but it does so by making requests wait, and a request that waits too long misses its deadline. Pacing, a form of rate limiting §9.38, starts work at no more than a fixed rate. Suppose each run of a downloaded decision program takes at most 3.2 milliseconds and a gateway starts at most one run every 4.5 milliseconds. Decision runs can then use at most , about 71%, of the processor however many requests arrive, and the rest remains for sensor sampling and radio work. That is the help.
Now three requests arrive together, a burst, and each needs its answer within 10 milliseconds of arrival, its deadline. Runs are served in arrival order.
Request 1 starts at time 0 and finishes at 3.2 milliseconds.
Request 2 starts at the next permitted start, 4.5 milliseconds, and finishes at milliseconds.
Request 3 starts at milliseconds and finishes at milliseconds.
The response time §9.32 of request 3, from arrival to answer, is 12.2 milliseconds: 9 milliseconds of waiting plus 3.2 milliseconds of running. It misses the 10-millisecond deadline by milliseconds. If such bursts come once a minute, the average load is milliseconds of work in every 60,000 milliseconds, about 0.016%. A low average says nothing about the worst response. An attacker who can send requests can also create bursts on purpose and push legitimate requests to the back of the queue.
A guarantee on response time needs a model of arrivals (the largest burst and the long-run rate), the worst-case service time of each request, the interference from other work, and the time spent waiting for resources that other work holds. Pacing supplies part of the arrival model; it guarantees no deadline by itself.
Does stopping a process after 40 seconds prove a 40-second WCET §9.33?
No. The worst-case execution time (WCET) of a computation is the longest time it can take, over every input and starting state, on the given hardware, when it runs without interruption. A rule that stops a process after 40 seconds is a timeout §9.34: it decides how long the caller is willing to wait, and it says nothing about how long the computation needs.
A stopped attempt is not a fast attempt. An attempt that would have needed 55 seconds is cut off at 40 and recorded as a failure, not as a 40-second success. The rule holds even if every attempt is stopped and none ever completes.
Selection hides the slow cases. Every attempt that completed did so within 40 seconds by construction, so the completed times say nothing about the stopped attempts, or about whether every attempt would finish within 40 seconds if left alone.
Stopping the wait is not stopping the work. Often a timeout ends only the caller’s wait, while the worker thread, a flash write or a radio transmission continues. To claim that the attempt ended, the system must cancel the work and confirm that it stopped; to claim that it ended within a time limit, the time needed to cancel must be added.
What the rule can give, once cancellation §9.29 is enforced and confirmed, is a bound on how long one attempt occupies the system: at most 40 seconds plus the time to cancel, whether the attempt completed or not. A 40-second WCET needs a different argument: an analysis of the longest path through the computation, with the cost of every step and every wait bounded.
Related entries: Instruction budget (fuel) (§2.32), Resource confinement (§2.40), Deadline versus timeout (§9.34), Schedulability (§9.37). Further reading: [89].