agora inbox for pgsql-committers@postgresql.orghelp / color / mirror / Atom feed
pgsql: Fix out-of-bounds access in autoprewarm worker 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix out-of-bounds access in autoprewarm worker @ 2026-06-26 17:54 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Tomas Vondra @ 2026-06-26 17:54 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix out-of-bounds access in autoprewarm worker The read stream callback apw_read_stream_next_block() advances p->pos through the block_info array. When processing the last block, it increments p->pos to prewarm_stop_idx before returning. The callback itself is safe because it checks bounds before accessing the array. However, the caller assigned blk from block_info[i] at the end of the loop body, before the loop condition was re-evaluated. When i equaled prewarm_stop_idx, this accessed memory beyond the allocated DSM segment, causing a segfault. Restructure the loop to check bounds at the top and assign blk at the beginning of the loop body, where it is always safe. This avoids the need for an explicit bounds check at the end. Backpatch to 18, where the bug was introduced by commit 6acab8bdbcda. Author: Matheus Alcantara <mths.dev@pm.me> Reported-by: Glauber Batista <glauberrbatista@gmail.com> Reviewed-by: Melanie Plageman <melanieplageman@gmail.com> Reviewed-by: Tomas Vondra <tomas@vondra.me> Backpatch-through: 18 Discussion: https://www.postgresql.org/message-id/CAO%2B_mTQgQyTYwDh%3DU8iTnsDmOGyWsZJjUV31SmEYwmw6_xY6Bw%40mail... Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/dac36601fd774a00b3b7390a656a689e2881bcf4 Modified Files -------------- contrib/pg_prewarm/autoprewarm.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix out-of-bounds access in autoprewarm worker @ 2026-06-26 17:54 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Tomas Vondra @ 2026-06-26 17:54 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix out-of-bounds access in autoprewarm worker The read stream callback apw_read_stream_next_block() advances p->pos through the block_info array. When processing the last block, it increments p->pos to prewarm_stop_idx before returning. The callback itself is safe because it checks bounds before accessing the array. However, the caller assigned blk from block_info[i] at the end of the loop body, before the loop condition was re-evaluated. When i equaled prewarm_stop_idx, this accessed memory beyond the allocated DSM segment, causing a segfault. Restructure the loop to check bounds at the top and assign blk at the beginning of the loop body, where it is always safe. This avoids the need for an explicit bounds check at the end. Backpatch to 18, where the bug was introduced by commit 6acab8bdbcda. Author: Matheus Alcantara <mths.dev@pm.me> Reported-by: Glauber Batista <glauberrbatista@gmail.com> Reviewed-by: Melanie Plageman <melanieplageman@gmail.com> Reviewed-by: Tomas Vondra <tomas@vondra.me> Backpatch-through: 18 Discussion: https://www.postgresql.org/message-id/CAO%2B_mTQgQyTYwDh%3DU8iTnsDmOGyWsZJjUV31SmEYwmw6_xY6Bw%40mail... Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3bf2cb22576eac50d80e3eecd485fcae4fdd7f8b Modified Files -------------- contrib/pg_prewarm/autoprewarm.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-06-26 17:54 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-06-26 17:54 pgsql: Fix out-of-bounds access in autoprewarm worker Tomas Vondra <tomas.vondra@postgresql.org> 2026-06-26 17:54 pgsql: Fix out-of-bounds access in autoprewarm worker Tomas Vondra <tomas.vondra@postgresql.org>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox