| From: | Andres Freund <andres(at)anarazel(dot)de> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: aio: Fix crash potential for pg_aios views due to late state upd |
| Date: | 2025-04-25 17:35:03 |
| Message-ID: | E1u8Mx5-001kvb-1k@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
aio: Fix crash potential for pg_aios views due to late state update
pgaio_io_reclaim() reset the fields in PgAioHandle before updating the state
to IDLE or incrementing the generation. For most things that's OK, but for
pg_get_aios() it is not - if it copied the PgAioHandle while fields were being
reset, we wouldn't detect that and could call
pgaio_io_get_target_description() with ioh->target == PGAIO_TID_INVALID,
leading to a crash.
Fix this issue by incrementing the generation and state earlier, before
resetting.
Also add an assertion to pgaio_io_get_target_description() for the target to
be valid - that'd have made this case a bit easier to debug. While at it,
add/update a few related assertions.
Author: Alexander Lakhin <exclusion(at)gmail(dot)com>
Discussion: https://postgr.es/m/062daca9-dfad-4750-9da8-b13388301ad9@gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/0d9114b7040d7503096e2897f4c856b17d461f6a
Modified Files
--------------
src/backend/storage/aio/aio.c | 21 +++++++++++++++------
src/backend/storage/aio/aio_target.c | 12 +++++++++---
2 files changed, 24 insertions(+), 9 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David E. Wheeler | 2025-04-25 19:13:02 | Re: extension_control_path and "directory" |
| Previous Message | Peter Eisentraut | 2025-04-25 14:58:08 | pgsql: Fix incorrect format placeholders |