Fix acting[] array out-of-bounds access in radostrace#87
Merged
pponnuvel merged 2 commits intotaodd:mainfrom Mar 31, 2026
Merged
Fix acting[] array out-of-bounds access in radostrace#87pponnuvel merged 2 commits intotaodd:mainfrom
pponnuvel merged 2 commits intotaodd:mainfrom
Conversation
pponnuvel
requested changes
Mar 25, 2026
5e275f3 to
ae72814
Compare
pponnuvel
reviewed
Mar 28, 2026
pponnuvel
reviewed
Mar 28, 2026
taodd
reviewed
Mar 29, 2026
Owner
taodd
left a comment
There was a problem hiding this comment.
Overall looks good to me, some minor suggestions
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>
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>
fe5f6bf to
36026aa
Compare
taodd
approved these changes
Mar 31, 2026
9a1fc27 to
36026aa
Compare
pponnuvel
approved these changes
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
acting[] was originally declared as acting[8] in commit a224791, with matching loop bounds of i < 8. Later, commit ada1407 reduced the array to acting[6] to make room for cls_ops[3], but forgot to update the loop bounds in radostrace.cc and radostrace.bpf.c, causing OOB access.