Skip to content

Commit d8f915d

Browse files
committed
Add soundness documentation page
Document what Kani checks (always-on and opt-in), what it does not check, and known soundness caveats (CBMC backend, bounded verification, floating-point, object size limits, function pointers). Resolves #1495 Signed-off-by: Felipe R. Monteiro <felisous@amazon.com>
1 parent 5f9031b commit d8f915d

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
- [Profiling Kani](./profiling.md)
4949

5050
- [Limitations](./limitations.md)
51+
- [Soundness](./soundness.md)
5152
- [Undefined behaviour](./undefined-behaviour.md)
5253
- [Rust feature support](./rust-feature-support.md)
5354
- [Intrinsics](./rust-feature-support/intrinsics.md)

docs/src/soundness.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Soundness
2+
3+
This page documents Kani's soundness guarantees and known limitations.
4+
5+
## What Kani Checks
6+
7+
Kani automatically checks for the following classes of issues:
8+
9+
### Always enabled
10+
- **Arithmetic overflow**: Addition, subtraction, multiplication, division,
11+
remainder, shift, and negation on integer types.
12+
- **Division by zero**: Integer and floating-point division and remainder.
13+
- **Pointer dereference validity**: Null pointers, dangling pointers, pointers
14+
to deallocated or dead objects, out-of-bounds pointers, misaligned pointers.
15+
- **Array bounds**: Index out of bounds on arrays and slices.
16+
- **Panics**: `assert!`, `unwrap()`, `expect()`, `panic!()`, `unreachable!()`,
17+
and any other panic path in the code under verification.
18+
- **Shift distance**: Negative shift amounts and shifts exceeding the bit width.
19+
- **Float-to-integer conversion**: Non-finite float values (NaN, infinity).
20+
- **NaN propagation**: NaN results from floating-point arithmetic.
21+
- **Memory leaks**: Dynamically allocated memory that is never freed.
22+
23+
### Opt-in (unstable)
24+
- **Valid value invariants** (`-Z valid-value-checks`): Checks that values meet
25+
their type's validity requirements (e.g., `bool` is 0 or 1, `char` is a valid
26+
Unicode scalar value, enum discriminants are in range).
27+
- **Uninitialized memory** (`-Z uninit-checks`): Checks that memory is
28+
initialized before being read through pointers.
29+
30+
## What Kani Does NOT Check
31+
32+
The following classes of undefined behavior are **not detected** by Kani:
33+
34+
- **Data races**: Kani verifies sequential code only. Concurrent programs are
35+
not supported.
36+
- **Pointer aliasing violations** (Stacked Borrows / Tree Borrows): Kani does
37+
not track reference lifetimes or enforce Rust's aliasing rules. If aliasing
38+
violations cause a memory safety or assertion failure, Kani will detect the
39+
symptom but not the root cause.
40+
- **Mutation of immutable data**: Same as aliasing — detected only if it causes
41+
an observable failure.
42+
- **Incorrect use of inline assembly**: Kani does not support inline assembly.
43+
Global assembly (`global_asm!`) is ignored with a warning.
44+
- **ABI violations**: Kani relies on `rustc` for ABI checking.
45+
- **Transmute to invalid values**: `kani::any()` always produces valid values,
46+
but `transmute` of invalid bit patterns is not detected unless `-Z
47+
valid-value-checks` is enabled.
48+
49+
## Soundness Caveats
50+
51+
### CBMC backend
52+
Kani uses [CBMC](https://github.com/diffblue/cbmc) as its verification backend.
53+
CBMC is a mature tool but, like any complex software, may contain bugs. Kani
54+
pins a specific CBMC version and runs CBMC's regression suite as part of its CI.
55+
56+
### Bounded verification
57+
Kani performs bounded model checking. Loops are unwound up to a configurable
58+
bound (`--default-unwind`). If the bound is insufficient, Kani emits an
59+
unwinding assertion failure. Verification results are sound only if all
60+
unwinding assertions pass.
61+
62+
### Floating-point arithmetic
63+
CBMC's floating-point reasoning uses bit-precise IEEE 754 semantics for the SAT
64+
backend. Results are sound for standard floating-point operations. However, some
65+
platform-specific floating-point behavior (e.g., x87 extended precision) may
66+
differ from the verification model.
67+
68+
### Object size limits
69+
CBMC represents pointers with a fixed number of object bits (default: 16,
70+
configurable via `--cbmc-args --object-bits N`). Programs that allocate more
71+
objects than `2^N` may exhibit incorrect wrapping behavior. This is a known
72+
limitation tracked in [#1150](https://github.com/model-checking/kani/issues/1150).
73+
74+
### Function pointers
75+
By default, unresolved function pointers are modeled as nondeterministic calls
76+
to any function with a compatible signature. The optional `--restrict-vtable`
77+
flag limits this to functions that appear in vtables, but this feature is
78+
experimental and may be imprecise.
79+
80+
## Reporting Soundness Issues
81+
82+
If you believe Kani has failed to detect a genuine issue (false negative),
83+
please file a bug report with the `[F] Soundness` label at
84+
[github.com/model-checking/kani/issues](https://github.com/model-checking/kani/issues).

0 commit comments

Comments
 (0)