Skip to content

src/osd/ECCommon.cc: fix use-after-free in do_read_op - #70853

Merged
shraddhaag merged 1 commit into
ceph:mainfrom
shraddhaag:wip-shraddhaag-fix-hobject
Aug 10, 2026
Merged

shraddhaag merged 1 commit into
ceph:mainfrom
shraddhaag:wip-shraddhaag-fix-hobject

Conversation

@shraddhaag

@shraddhaag shraddhaag commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

We saw an assert in ECCommon::ReadOp::print, surfacing as ceph_assert(!max || (*this == hobject_t(hobject_t::get_max()))).

ERROR 2026-08-03 08:01:12,448 [shard 1:main] osd - /ceph/rpmbuild/BUILD/ceph-21.3.0-1655-g9b3679cc/src/common/hobject.h:240 : In function 'bool hobject_t::is_max() const', ceph_assert(!max || (*this == hobject_t(hobject_t::get_max())))
ERROR 2026-08-03 08:01:12,448 [shard 1:main] osd - Aborting Got SIGABRT on shard 1 - Stopping all shards
Backtrace:
  0# 0x00007F655FABEF8C in /lib64/libc.so.6
 1# gsignal in /lib64/libc.so.6
 2# abort in /lib64/libc.so.6
 3# ceph::__ceph_assert_fail(char const*, char const*, int, char const*) in ceph-osd
 4# void ceph::__ceph_assert_fail<&(LogClient::_get_mon_log_message()::{lambda(bool)#1}::operator()(bool) const::assert_data_ctx)>() at :?
 5# hobject_t::is_max() const at /usr/src/debug/ceph-21.3.0-1655.g9b3679cc.el10.x86_64/src/common/hobject.h:240 (discriminator 11)
 6# operator<<(std::ostream&, hobject_t const&) in ceph-osd
 7# ECCommon::ReadOp::print(std::ostream&) const at :?
 8# ECCommon::ReadPipeline::do_read_op(ECCommon::ReadOp&) in ceph-osd
 9# ECCommon::ReadPipeline::objects_read_and_reconstruct(std::map<hobject_t, std::__cxx11::list<ec_align_t, std::allocator<ec_align_t> >, std::less<hobject_t>, std::allocator<std::pair<hobject_t const, std::__cxx11::list<ec_align_t, std::allocator<ec_align_t> > > > > const&, bool, unsigned long, std::unique_ptr<GenContext<std::map<hobject_t, ECCommon::ec_extent_t, std::less<hobject_t>, std::allocator<std::pair<hobject_t const, ECCommon::ec_extent_t> > >&&>, std::default_delete<GenContext<std::map<hobject_t, ECCommon::ec_extent_t, std::less<hobject_t>, std::allocator<std::pair<hobject_t const, ECCommon::ec_extent_t> > >&&> > >&&) in ceph-osd
10# crimson::osd::ECBackend::_read(hobject_t const&, unsigned long, unsigned long, unsigned long, unsigned int) in ceph-osd
11# crimson::osd::PGBackend::read(ObjectState const&, OSDOp&, object_stat_sum_t&) in ceph-osd
12# crimson::osd::OpsExecuter::do_execute_op(OSDOp&) in ceph-osd
13# crimson::osd::OpsExecuter::execute_op(OSDOp&) in ceph-osd

Inpecting the hobject in hobject_t::is_max(), it became clear that the memory is being streamed after being freed.

Root Cause

ECCommon::ReadPipeline::do_read_op, at the very end in the WITH_CRIMSON block:

#if WITH_CRIMSON
  if (local_read_op) {
    dout(10) << __func__ << ": doing local read for " << rop << dendl;
    handle_sub_read_n_reply(
        get_parent()->whoami_shard(), *local_read_op, rop.trace);
  }
#endif
dout(10) << __func__ << ": started " << rop << dendl;

In handle_sub_read_n_reply, seastore can sometimes serve the read from cache. If the read doesn't require anything from other shards and the op completes inline after the cache read, as seen in logs:

DEBUG 2026-08-04 19:23:51,441 [shard 0:main] seastore_cache - 0x400000afbc00 trans.565 Cache::read_extents_maybe_partial: reading extent CachedExtent(addr=0x400000f88900, type=OBJECT_DATA_BLOCK, trans=0, version=0, dirty_from=JOURNAL_SEQ_NULL, modify_time=tp(NULL), paddr=paddr<Seg[Dev(0x0),0x16],0x16f000>, prior_paddr=nullopt, length=0x1000, loaded=0x1000, state=CLEAN, pin_state=Fresh, last_committed_crc=2906653802, refcount=4, user_hint=Hint(NULL), write_policy=WRITE_BACK, rewrite_gen=GEN_NULL, pending_io=N/A, laddr=L0x8c05f07fde2a4430000000000000(0,4,602f83fe,3c54886,0,0,0), seen=1) 0x0~0x1000 ...
DEBUG 2026-08-04 19:23:51,441 [shard 0:main] seastore_cache - Cache::read_extents_maybe_partial: extent loaded
DEBUG 2026-08-04 19:23:51,441 [shard 0:main] seastore_odata - 0x400000afbc00 trans.565 ObjectDataHandler::read: got extent: CachedExtent(addr=0x400000f88900, type=OBJECT_DATA_BLOCK, trans=0, version=0, dirty_from=JOURNAL_SEQ_NULL, modify_time=tp(NULL), paddr=paddr<Seg[Dev(0x0),0x16],0x16f000>, prior_paddr=nullopt, length=0x1000, loaded=0x1000, state=CLEAN, pin_state=Fresh, last_committed_crc=2906653802, refcount=4, user_hint=Hint(NULL), write_policy=WRITE_BACK, rewrite_gen=GEN_NULL, pending_io=N/A, laddr=L0x8c05f07fde2a4430000000000000(0,4,602f83fe,3c54886,0,0,0), seen=1)
DEBUG 2026-08-04 19:23:51,441 [shard 0:main] seastore - 0x400000afbc00 trans.565 SeaStoreS::_read: got bl length=0x1000
DEBUG 2026-08-04 19:23:51,441 [shard 0:main] seastore_t - 0x400000afbc00 trans.565 Cache::on_transaction_destruct: done 7(40960B) read

Since the read op completes inline, the pipeline completes sychronously and in complete_read_op() tid and its corresponding ReadOp is erased from tid_to_read_map, effectively leaving a dangling rop:

  // if the read op is over. clean all the data of this tid.
  for (auto& pg_shard : rop.in_progress) {
    shard_to_read_map[pg_shard].erase(rop.tid);
  }
  rop.in_progress.clear();
  tid_to_read_map.erase(rop.tid);

When this returns, the dout in ECCommon::ReadPipeline::do_read_op after the
WITH_CRIMSON block, when trying to print the rop, tries to dereference freed memory and crashes, leading to the above failure.

Solution

Simply moving the dout to before the WITH_CRIMSON block fixes the use-after-free issue.

09dea78 only this commit is relevant. The other two commits are from #70833.

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

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.

@shraddhaag

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@shraddhaag
shraddhaag marked this pull request as ready for review August 6, 2026 10:59
@shraddhaag
shraddhaag requested review from a team as code owners August 6, 2026 10:59
@shraddhaag
shraddhaag force-pushed the wip-shraddhaag-fix-hobject branch from 47209fb to 09dea78 Compare August 6, 2026 11:18

@knrt10 knrt10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath10-testing-20260806.013257-main.

@shraddhaag

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@shraddhaag

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@shraddhaag

Copy link
Copy Markdown
Contributor Author

jenkins test api

@shraddhaag

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@shraddhaag
shraddhaag force-pushed the wip-shraddhaag-fix-hobject branch from 09dea78 to f119131 Compare August 10, 2026 03:33
@shraddhaag

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@shraddhaag

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

Issue: We saw an assert in ECCommon::ReadOp::print, surfacing as
ceph_assert(!max || (*this == hobject_t(hobject_t::get_max()))).

Inpecting the hobject in hobject_t::is_max(), it became clear that
the memory is being streamed after being freed.

After investigation, ECCommon::ReadPipeline::do_read_op, at the
very end in the WITH_CRIMSON block, via handle_sub_read_n_reply,
when seastore serves the read from cache, the pipeline completes
sychronously and in complete_read_op() tid is cleared from
tid_to_read_map, effectively freeing rop. The dout after the
WITH_CRIMSON block, when trying to print the rop, tries to
dereference freed memory and crashes.

Solution:
Simply moving the dout to before the WITH_CRIMSON block fixes the
use-after-free issue.

Fixes: https://tracker.ceph.com/issues/78772
Signed-off-by: Shraddha Agrawal <[email protected]>
@shraddhaag
shraddhaag force-pushed the wip-shraddhaag-fix-hobject branch from f119131 to 606a817 Compare August 10, 2026 09:56
@shraddhaag

Copy link
Copy Markdown
Contributor Author

@perezjosibm perezjosibm moved this from Needs QA to QA in Progress in Crimson Aug 10, 2026
@shraddhaag
shraddhaag merged commit abbf9ad into ceph:main Aug 10, 2026
7 checks passed
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/31391995728

@perezjosibm perezjosibm moved this from QA in Progress to Merged (Main) in Crimson Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Merged (Main)

Development

Successfully merging this pull request may close these issues.

4 participants