Skip to content

rgw/amqp: check the iterator before dereferencing it - #71666

Merged
tchaikov merged 1 commit into
ceph:mainfrom
tchaikov:wip-rgw-amqp-oob-read
Sep 11, 2026
Merged

tchaikov merged 1 commit into
ceph:mainfrom
tchaikov:wip-rgw-amqp-oob-read

Conversation

@tchaikov

@tchaikov tchaikov commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

A broker can confirm several messages at once by setting the "multiple" flag, which acks every delivery tag up to and including the one in the frame. The loop that invokes those callbacks tests it->tag before testing whether it still points at an element:

  while (it->tag <= tag && it != conn->callbacks.end()) {

erase() returns end() once the last callback is gone, so the next iteration reads past the end of the list. Swap the two conditions.

Reaching it takes an ack that covers every callback still pending on the connection. Any callback left over keeps the loop inside the list, which is why this has not caused trouble so far.

Fixes: https://tracker.ceph.com/issues/80464

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@tchaikov
tchaikov requested a review from a team as a code owner September 10, 2026 02:49
@tchaikov
tchaikov requested a review from yuvalif September 10, 2026 02:49
@github-actions github-actions Bot added the rgw label Sep 10, 2026
@tchaikov

Copy link
Copy Markdown
Contributor Author

@yuvalif hi Yuval, do you mind taking a look?

@yuvalif

yuvalif commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

@tchaikov problem looks real, but this is strange. this should have crashed every time we drain the callback queue.

@yuvalif

yuvalif commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

could you please open a tracker as mark backports as: umbrella, tentacle (and squid?)

@tchaikov

Copy link
Copy Markdown
Contributor Author

@tchaikov problem looks real, but this is strange. this should have crashed every time we drain the callback queue.

@yuvalif . this is indeed an interesting topic. but IIUC, it can't crash, because the read stays inside the vector's own allocation. CallbackList is a std::vector<>, and erase() doesn't shrink the buffer, so after the last erase(), size() < capacity() and it == end() points at a slot that is still part of the block. that slot holds the moved-from copy of the element that was shifted out, and its tag field still has the old value, so it->tag <= tag is true and the it != end() check ends the loop.

A broker can confirm several messages at once by setting the "multiple"
flag, which acks every delivery tag up to and including the one in the
frame. The loop that invokes those callbacks tests it->tag before
testing whether it still points at an element:

  while (it->tag <= tag && it != conn->callbacks.end()) {

erase() returns end() once the last callback is gone, so the next
iteration reads past the end of the list. Swap the two conditions.

Reaching it takes an ack that covers every callback still pending on
the connection. Any callback left over keeps the loop inside the list,
which is why this has not caused trouble so far.

Fixes: https://tracker.ceph.com/issues/80464
Signed-off-by: Kefu Chai <[email protected]>
@tchaikov
tchaikov force-pushed the wip-rgw-amqp-oob-read branch from 3c0bcb8 to 88d2208 Compare September 11, 2026 05:34
@tchaikov

tchaikov commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor Author

could you please open a tracker as mark backports as: umbrella, tentacle (and squid?)

sure. created https://tracker.ceph.com/issues/80464

@tchaikov
tchaikov merged commit 5d671ce into ceph:main Sep 11, 2026
21 of 24 checks passed
@tchaikov
tchaikov deleted the wip-rgw-amqp-oob-read branch September 11, 2026 09:43
aainscow pushed a commit to aainscow/ceph that referenced this pull request Sep 18, 2026
rgw/amqp: check the iterator before dereferencing it

Reviewed-by: Yuval Lifshitz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants