pub enum Safety {
Off,
Detect,
Enforce,
Kernel,
}Expand description
How much of the memory safety monitor is on, from -fsafety=.
Design: spec/safe-memory/15-integration.md section 15.4. One flag rather than a plane at a
time, because the tiers of spec/safe-memory/02-threat-model.md are the product and the
modifiers are how somebody who has read that document departs from one.
The tiers agree about which accesses are checked and disagree about what happens when a check says no and about how much of the boundary is covered. That is why they are one value here and not three booleans: a build asks for a tier, and everything else follows from it.
Variants§
Off
-fsafety=off. No checks and no runtime. The default, and what every existing build gets.
Detect
-fsafety=detect. Tier D: report and carry on, for a test run or a fuzzer.
Enforce
-fsafety=enforce. Tier E: report and stop, for a program that faces the network.
Kernel
-fsafety=kernel. Tier K: what a kernel can afford, with the allocator and the libc
wrappers taken out because a kernel has neither.
Implementations§
Source§impl Safety
impl Safety
Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
The spelling this tier is asked for by, without the flag in front of it.
Sourcepub const fn instruments(self) -> bool
pub const fn instruments(self) -> bool
Whether checks are inserted at all.
The three tiers that are not off all insert the same checks at this milestone. What
separates them is the reporter and the boundary, which are milestones S2 and S3 in
spec/safe-memory/16-milestones.md.