Commit d3075dc
committed
fix(net): tighten sendto non-IP fall-through to close a destination-policy TOCTOU
Splits the high-priority sendto half out of #130 (per the maintainer's request
to land it as a fix that can go in quickly).
A non-IP sendto with no fs-path gate previously fell through to `_ => Continue`,
letting the kernel re-read `sockfd` and the destination after the supervisor's
decision. Under an active destination policy a child could race a
`dup2(inet_sock, sockfd)` + address swap into that window and ride the Continue
out to a denied IP.
Under `has_net_destination_policy` the arm no longer Continues: it pins the fd
via `dup_fd_from_pid`, classifies on the STABLE socket domain via the new pure
`classify_send_path` helper, and either sends the unix datagram on-behalf on the
pinned fd (UnixOnBehalf) or fails closed with EAFNOSUPPORT. With no destination
policy there is nothing to bypass, so Continue is preserved. The non-UnixOnBehalf
outcomes collapse to a single fail-closed errno arm rather than unreachable!(),
so any future drift in the classifier fails closed instead of panicking (a panic
on this seccomp-notif path would unwind the supervisor and DoS the sandbox).
The pure `classify_send_path` helper and its 4 unit tests land here (sendto is
its first consumer); `send_path_non_ip_on_non_unix_socket_is_rejected` is the
deterministic fail-without-fix witness (pre-fix logic yielded Continue). The
sendmsg/sendmmsg symmetric rework consumes the same helper and stays in draft
#130 — so until #130 lands, sendto and sendmsg differ on a non-IP unix datagram
(sendto sends on-behalf, sendmsg still returns EAFNOSUPPORT); this preserves the
pre-existing sendto behavior (it already sent via Continue) while closing its
TOCTOU, and #130 aligns sendmsg.
Behavior scope (fail-closed hardening, only under a destination policy): a non-IP
send on a non-unix/non-IP datagram family (AF_PACKET/AF_VSOCK/...) now returns
EAFNOSUPPORT instead of Continue; abstract/named-fs-gate-off unix datagrams now
send on-behalf, so the receiver observes the supervisor's SO_PEERCRED rather than
the child's. Same Continue-shape as the chroot AF_UNIX gate report (#143).1 parent 8b5eccf commit d3075dc
2 files changed
Lines changed: 129 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
131 | 178 | | |
132 | 179 | | |
133 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
79 | 120 | | |
80 | 121 | | |
81 | 122 | | |
| |||
120 | 161 | | |
121 | 162 | | |
122 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
123 | 203 | | |
0 commit comments