osd_test: Answer etcd calls one by one in test_peering_flush_same_epoch_repeer #222

Open
koolkhel wants to merge 1 commits from koolkhel/vitastor:same-epoch-repeer-test-uaf into master
Contributor

Description

test_peering_flush_same_epoch_repeer unpaused the etcd mock, which then answers a txn and its watch inside etcd_txn(). The test passes on master only because the stopping PG's nested state report fails its compare and is retried from a timer. If that report succeeds at once, its callback erases the PG (osd_cluster.cpp, "Forget offline PGs after reporting their state"), and stop_pg() goes on with the freed PG in pg_cancel_flush_waiting_ops(). ASan reports a heap-use-after-free there.

Keep the mock paused and answer the queued calls one by one from the test, as a real etcd client does from the event loop. Test-only change.

Found: by AddressSanitizer on a branch where that nested report succeeds at once; master is not affected as is.

Tested: osd_test built with WITH_ASAN=yes passes. With the OSD change of ec743998 reverted, the test still fails on the behaviour (stabilize sent before the history, PG active without OSD 3, object incomplete).

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description test_peering_flush_same_epoch_repeer unpaused the etcd mock, which then answers a txn and its watch inside etcd_txn(). The test passes on master only because the stopping PG's nested state report fails its compare and is retried from a timer. If that report succeeds at once, its callback erases the PG (osd_cluster.cpp, "Forget offline PGs after reporting their state"), and stop_pg() goes on with the freed PG in pg_cancel_flush_waiting_ops(). ASan reports a heap-use-after-free there. Keep the mock paused and answer the queued calls one by one from the test, as a real etcd client does from the event loop. Test-only change. Found: by AddressSanitizer on a branch where that nested report succeeds at once; master is not affected as is. Tested: osd_test built with WITH_ASAN=yes passes. With the OSD change of ec743998 reverted, the test still fails on the behaviour (stabilize sent before the history, PG active without OSD 3, object incomplete). ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-12-02 15:33:07 +03:00
The test unpaused the etcd mock, which then answers a txn and its watch
inside etcd_txn(). It passes only because the stopping PG's nested state
report fails its compare and is retried from a timer. If that report
succeeds, its callback erases the PG and stop_pg() goes on with the freed
PG (a heap-use-after-free under ASan). Keep the mock paused and answer the
queued calls one by one from the test, as a real etcd client does from
the event loop.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u same-epoch-repeer-test-uaf:koolkhel-same-epoch-repeer-test-uaf
git checkout koolkhel-same-epoch-repeer-test-uaf
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#222
No description provided.