Repository navigation
Commit 16d0012
committed
fix(sandbox): document unsafe blocks and enforce SAFETY comments with clippy
Every non-test unsafe block in openshell-sandbox now carries a
// SAFETY: comment stating its invariant, and
clippy::undocumented_unsafe_blocks is enabled at warn level in the
crate roots (lib, the sandbox bin, and the seccomp-perf bin), so the
CI clippy lanes with -D warnings fail the build on new undocumented
blocks. Test-only blocks are exempt through cfg_attr(test, allow) to
keep this change free of test-comment churn; the lint fires 89 times
on main and zero times after this change.
reset_child_signal_dispositions gains a # Safety section documenting
its caller contract (forked pre-exec child only), and the vsock
control stream reinterpreted as a UnixStream is documented in place:
the family-agnostic operations it relies on, the AF_UNIX members that
must never be called on it, and the dial-side twin of the same
reinterpretation.
Small mechanical edits were required so each comment sits on the line
directly above its unsafe block (the lint is line-anchored): nine
expressions hoisted into let bindings or nested ifs (five syscall
probes in main.rs, two F_SETFL guards in network_broker.rs, two in
boundary_server.rs), plus two reorderings (a timeout binding in
network_broker.rs, the SAFETY comment placement in seccomp_notify.rs).
Every movement preserves the original short-circuits and the errno
adjacency the probe helpers rely on, and four new tests pin those
properties: two run the self-protection probes against seccomp filters
(one lets the FIOSETOWN ioctl through to the kernel, so a probe that
reads another syscall's errno fails), and two cover the F_SETFL error
arms in connect_exact (an O_PATH descriptor for the transition
failure, a deny filter for the restore failure).
multiple_unsafe_ops_per_block is deliberately not enabled: it is
restriction-group and needs block splits at production sites owned by
#5180.
Closes #5188
Signed-off-by: Emilien Macchi <emacchi@redhat.com>1 parent 74eacee commit 16d0012
8 files changed
Lines changed: 438 additions & 35 deletions
File tree
- crates/openshell-sandbox/src
- bin
- linux
- sandbox/linux
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4828 | 4828 | | |
4829 | 4829 | | |
4830 | 4830 | | |
| 4831 | + | |
| 4832 | + | |
4831 | 4833 | | |
4832 | 4834 | | |
4833 | 4835 | | |
| |||
4838 | 4840 | | |
4839 | 4841 | | |
4840 | 4842 | | |
| 4843 | + | |
| 4844 | + | |
4841 | 4845 | | |
4842 | 4846 | | |
4843 | 4847 | | |
| |||
4846 | 4850 | | |
4847 | 4851 | | |
4848 | 4852 | | |
| 4853 | + | |
| 4854 | + | |
4849 | 4855 | | |
4850 | 4856 | | |
4851 | 4857 | | |
| |||
4856 | 4862 | | |
4857 | 4863 | | |
4858 | 4864 | | |
| 4865 | + | |
4859 | 4866 | | |
4860 | 4867 | | |
4861 | 4868 | | |
| |||
4879 | 4886 | | |
4880 | 4887 | | |
4881 | 4888 | | |
| 4889 | + | |
| 4890 | + | |
| 4891 | + | |
4882 | 4892 | | |
4883 | 4893 | | |
4884 | 4894 | | |
| |||
4890 | 4900 | | |
4891 | 4901 | | |
4892 | 4902 | | |
| 4903 | + | |
| 4904 | + | |
| 4905 | + | |
4893 | 4906 | | |
4894 | | - | |
| 4907 | + | |
4895 | 4908 | | |
4896 | 4909 | | |
4897 | 4910 | | |
| |||
5086 | 5099 | | |
5087 | 5100 | | |
5088 | 5101 | | |
5089 | | - | |
5090 | | - | |
| 5102 | + | |
| 5103 | + | |
| 5104 | + | |
| 5105 | + | |
| 5106 | + | |
| 5107 | + | |
| 5108 | + | |
| 5109 | + | |
| 5110 | + | |
| 5111 | + | |
| 5112 | + | |
| 5113 | + | |
| 5114 | + | |
| 5115 | + | |
| 5116 | + | |
| 5117 | + | |
| 5118 | + | |
| 5119 | + | |
| 5120 | + | |
| 5121 | + | |
5091 | 5122 | | |
5092 | 5123 | | |
5093 | 5124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
6 | 11 | | |
7 | 12 | | |
8 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
831 | 831 | | |
832 | 832 | | |
833 | 833 | | |
834 | | - | |
835 | | - | |
836 | 834 | | |
837 | 835 | | |
838 | 836 | | |
| |||
841 | 839 | | |
842 | 840 | | |
843 | 841 | | |
| 842 | + | |
| 843 | + | |
844 | 844 | | |
845 | 845 | | |
846 | 846 | | |
| |||
0 commit comments