Commit 18cd218
authored
Fix acting[] array out-of-bounds access in radostrace (#87)
* Fix acting[] array out-of-bounds access in radostrace
The acting[] array in client_op_v was defined with a fixed size of 6,
but the loop iterating over it used a hardcoded bound of 8, causing
out-of-bounds reads. Beyond fixing the mismatch, the array was too
small for real Ceph deployments.
Ceph caps the number of OSDs per PG at CEPH_PG_MAX_SIZE (16), defined
in src/include/rados.h. This applies to both replicated pools (max
size=10 enforced by OSDMonitor) and erasure-coded pools (k+m bounded
by CEPH_PG_MAX_SIZE). The Linux kernel client uses the same constant
to size its acting set arrays (struct ceph_osds in osdmap.h).
Changes:
- Define MAX_ACTING=16 macro in bpf_ceph_types.h, matching
CEPH_PG_MAX_SIZE from Ceph's rados.h
- Use MAX_ACTING for acting[] array size and all loop bounds
- Move initialize_value() stack allocation to a .bss global
(zero_val) to avoid BPF 512-byte stack limit, since client_op_v
with acting[16] is ~434 bytes
Signed-off-by: Seyeong Kim <seyeong.kim@canonical.com>
* Fix ringbuf reserve size mismatch in uprobe_finish_op
bpf_ringbuf_reserve() was using sizeof(struct op_v) but the code
copies a struct client_op_v into the reserved buffer. With the
acting[] array expansion this became a detectable OOB write caught
by the BPF verifier.
Signed-off-by: Seyeong Kim <seyeong.kim@canonical.com>
---------
Signed-off-by: Seyeong Kim <seyeong.kim@canonical.com>1 parent 4f3d470 commit 18cd218
3 files changed
Lines changed: 9 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
57 | | - | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
42 | 44 | | |
43 | | - | |
44 | | - | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
| 201 | + | |
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
323 | | - | |
| 323 | + | |
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | | - | |
| 285 | + | |
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| |||
0 commit comments