Commit 0505e2a
authored
fix(fileservice): validate remote cache payloads (#25969)
The remote-cache RPC boundary trusted request shape and response indexes.
Schema-valid requests with an empty key list or an omitted nested `CacheKey`
could panic the serving CN. A malformed or inconsistent response could use a
negative/out-of-range index, an index requested from a different target, or an
incorrect data length to panic the requester or mark invalid bytes as a hit.
Validate every request entry before allocating the I/O vector, require all
keys in one request to name the same file, and return `bad request` without
installing a response release callback on invalid input. If `ReadCache`
partially acquires cache data and then fails, release it immediately.
On the client, accept only indexes sent to that target, reject out-of-bounds
and wrong-length hits, and let the normal local-storage path handle every
invalid response. An invalid hit does not consume its index, while the first
fully valid response wins. The MORPC response is released on all received
response paths.
Normal same-version senders already generate valid shapes; nil repeated
message pointers are only possible for direct in-process callers. The network-
relevant cases are empty/missing nested request fields and invalid scalar
response indexes/lengths.
Validation:
- focused fileservice regressions: PASS
- focused fileservice regressions with `-race -count=10`: PASS
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=240s ./pkg/fileservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s ./pkg/cnservice`
- `go build ./pkg/fileservice ./pkg/cnservice` (repository CGo environment)
- `go vet ./pkg/fileservice ./pkg/cnservice` (repository CGo environment)
Approved by: @gouhongshen, @XuPeng-SH1 parent 647cbe6 commit 0505e2a
3 files changed
Lines changed: 331 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1187 | 1187 | | |
1188 | 1188 | | |
1189 | 1189 | | |
1190 | | - | |
1191 | 1190 | | |
1192 | 1191 | | |
1193 | 1192 | | |
| |||
1230 | 1229 | | |
1231 | 1230 | | |
1232 | 1231 | | |
1233 | | - | |
| 1232 | + | |
1234 | 1233 | | |
1235 | 1234 | | |
1236 | 1235 | | |
| |||
1249 | 1248 | | |
1250 | 1249 | | |
1251 | 1250 | | |
1252 | | - | |
| 1251 | + | |
1253 | 1252 | | |
1254 | 1253 | | |
1255 | 1254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
117 | 121 | | |
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
121 | 125 | | |
122 | | - | |
| 126 | + | |
123 | 127 | | |
124 | 128 | | |
125 | 129 | | |
126 | 130 | | |
127 | 131 | | |
| 132 | + | |
128 | 133 | | |
129 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
130 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
131 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
132 | 151 | | |
133 | 152 | | |
134 | 153 | | |
135 | 154 | | |
136 | 155 | | |
| 156 | + | |
| 157 | + | |
137 | 158 | | |
138 | 159 | | |
139 | 160 | | |
| |||
162 | 183 | | |
163 | 184 | | |
164 | 185 | | |
165 | | - | |
| 186 | + | |
166 | 187 | | |
167 | 188 | | |
168 | | - | |
169 | | - | |
170 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
171 | 192 | | |
| 193 | + | |
172 | 194 | | |
173 | 195 | | |
174 | 196 | | |
175 | 197 | | |
176 | | - | |
177 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
178 | 203 | | |
179 | 204 | | |
180 | 205 | | |
181 | 206 | | |
| 207 | + | |
182 | 208 | | |
183 | 209 | | |
184 | | - | |
185 | | - | |
| 210 | + | |
| 211 | + | |
186 | 212 | | |
187 | 213 | | |
188 | 214 | | |
| |||
0 commit comments