Skip to content

mon/MonClient: drop the ping connection before deleting its messenger - #72378

Merged
rzarzynski merged 1 commit into
ceph:mainfrom
aainscow:wip-monc-ping-uaf
Nov 5, 2026
Merged

rzarzynski merged 1 commit into
ceph:mainfrom
aainscow:wip-monc-ping-uaf

Conversation

@aainscow

@aainscow aainscow commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

MonClient::ping_monitor() deletes its temporary messenger while its ConnectionRef is still in scope. The last reference is dropped when the function returns, and ~AsyncConnection then reads async_msgr->cct from the freed messenger:

#0 ceph::logging::SubsystemMap::should_gather<30u, 20>
#2 AsyncConnection::~AsyncConnection (msg/async/AsyncConnection.cc:162)
#7 MonClient::ping_monitor (mon/MonClient.cc:331)
#8 librados::RadosClient::ping_monitor

On a vstart cluster with cephx, ceph ping mon.X segfaulted in 164 of 180 attempts, and qa/workunits/cephtool/test.sh failed in test_mon_ping. The teardown order is old, but until #71797 pings with cephx asserted earlier on debug builds and never reached the teardown.

This releases the connection before shutting the messenger down. With the change, 180 pings against the same cluster did not crash, and the cephtool workunits (--test-mon --test-osd --test-mgr, --test-mds) and mon/pool_ops.sh pass.

Testing: no new test. Catching a use-after-free like this deterministically needs a live monitor with cephx and a memory checker, so a unit test is not practical. The existing cephtool test_mon_ping and src/test/pybind/test_rados.py::test_ping_monitor (rados python workunit) exercise this path with cephx; test_mon_ping crashed without the fix.

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

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.

🤖 Generated with Claude Code

@batrick

batrick commented Oct 6, 2026

Copy link
Copy Markdown
Member

@aainscow needs sign off

ping_monitor() deletes its temporary messenger while its ConnectionRef
is still in scope, so the last reference goes when the function returns
and ~AsyncConnection then reads async_msgr->cct from the freed messenger.
With cephx, "ceph ping mon.X" segfaulted in 164 of 180 attempts on a
vstart cluster:

  SubsystemMap::should_gather
  AsyncConnection::~AsyncConnection
  MonClient::ping_monitor
  librados::RadosClient::ping_monitor

Release the connection before shutting the messenger down. After this,
180 pings had no crashes.

Fixes: https://tracker.ceph.com/issues/81400
Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath7-testing-20261012.100201-main.

@tchaikov tchaikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. but shall we backport this change? the description in the tracker ticket puts

On a vstart cluster with cephx (debug build of main as of c5f516a), ceph ping mon.a|b|c segfaulted in 164 of 180 attempts.

so, it's rare and the impact to production is small. but on the other side, the change is focused and safe.

@ljflores

Copy link
Copy Markdown
Member

The PR is set to backport it to umbrella and tentacle.

@Jayaprakash-ibm

Copy link
Copy Markdown
Contributor

@rzarzynski
rzarzynski merged commit e0928d2 into ceph:main Nov 5, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants