Skip to content

fix(storage): pin Arrow registry entries with shared_ptr to prevent use-after-free - #938

Merged
adsharma merged 1 commit into
mainfrom
fix_arrow_use_after_free
Sep 7, 2026
Merged

fix(storage): pin Arrow registry entries with shared_ptr to prevent use-after-free#938
adsharma merged 1 commit into
mainfrom
fix_arrow_use_after_free

Conversation

@adsharma

@adsharma adsharma commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #933.

Problem

getArrowData()/getArrowRelData() in src/storage/table/arrow_table_support.cpp returned raw pointers into the process-wide registry maps after the lock_guard went out of scope. The mutex protected individual map operations, not the lifetime of data a caller already held a pointer into. A concurrent DROP TABLEunregisterArrowData()unordered_map::erase left the other thread with a dangling pointer (CWE-416 use-after-free, CWE-667 improper locking).

Fix

  • Registry payloads are now shared_ptr<ArrowTableData> / shared_ptr<ArrowRelTableData>.
  • getArrowData()/getArrowRelData() return a shared_ptr copy taken under the mutex, so callers pin the buffers past the lock scope; erasing the map entry only drops the registry's reference.
  • ArrowNodeTable/ArrowRelTable each hold a pin plus shallow non-owning views into the pinned data; table destructors still call unregisterArrowData() for cleanup, now safe under concurrency.
  • StorageManager creation path uses the pinning getters, closing the get-then-copy TOCTOU.

Testing

  • make release clean.
  • build/release/test/api/api_test --gtest_filter="*Arrow*:*arrow*" → 141 passed, 21 skipped (pre-existing skips).
  • Targeted drop/recreate tests pass.

…se-after-free

getArrowData()/getArrowRelData() returned raw pointers into the
process-wide registry after the lock_guard went out of scope, so a
concurrent DROP TABLE / unregisterArrowData() (unordered_map::erase)
left callers with dangling pointers (CWE-416/667).

Store registry payloads as shared_ptr and return a shared_ptr copy
taken under the mutex so callers pin the buffers past the lock scope.
ArrowNodeTable/ArrowRelTable keep a pin plus shallow non-owning views;
erasing the map entry now only drops the registry's reference.

Fixes #933.
@adsharma
adsharma merged commit 0e81143 into main Sep 7, 2026
4 checks passed
@adsharma
adsharma deleted the fix_arrow_use_after_free branch September 7, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use-after-free in the Arrow table registry (arrow_table_support.cpp)

1 participant