pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on @ 2022-11-19 21:56 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 6+ messages in thread From: Andres Freund @ 2022-11-19 21:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on 32bit ProcSleep() used a PGPROC* variable to point to PROC_QUEUE->links.next, because that does "the right thing" with SHMQueueInsertBefore(). While that largely works, it's certainly not correct and unnecessary - we can just use SHM_QUEUE* to point to the insertion point. Noticed when testing a 32bit of postgres with undefined behavior sanitizer. UBSan noticed that sometimes the supposed PGPROC wasn't sufficiently aligned (required since 46d6e5f5679, ensured indirectly, via ShmemAllocRaw() guaranteeing cacheline alignment). For now fix this by using a SHM_QUEUE* for the insertion point. Subsequently we should replace all the use of PROC_QUEUE and SHM_QUEUE with ilist.h, but that's a larger change that we don't want to backpatch. Backpatch to all supported versions - it's useful to be able to run postgres under UBSan. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/20221117014230.op5kmgypdv2dtqsf@awork3.anarazel.de Backpatch: 11- Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/fc4154286e0e47d748d19183fd05be794a019be8 Modified Files -------------- src/backend/storage/lmgr/proc.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on @ 2022-11-19 21:56 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 6+ messages in thread From: Andres Freund @ 2022-11-19 21:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on 32bit ProcSleep() used a PGPROC* variable to point to PROC_QUEUE->links.next, because that does "the right thing" with SHMQueueInsertBefore(). While that largely works, it's certainly not correct and unnecessary - we can just use SHM_QUEUE* to point to the insertion point. Noticed when testing a 32bit of postgres with undefined behavior sanitizer. UBSan noticed that sometimes the supposed PGPROC wasn't sufficiently aligned (required since 46d6e5f5679, ensured indirectly, via ShmemAllocRaw() guaranteeing cacheline alignment). For now fix this by using a SHM_QUEUE* for the insertion point. Subsequently we should replace all the use of PROC_QUEUE and SHM_QUEUE with ilist.h, but that's a larger change that we don't want to backpatch. Backpatch to all supported versions - it's useful to be able to run postgres under UBSan. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/20221117014230.op5kmgypdv2dtqsf@awork3.anarazel.de Backpatch: 11- Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c13667b518e3ff21fd756b571302acd6f8688e45 Modified Files -------------- src/backend/storage/lmgr/proc.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on @ 2022-11-19 21:56 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 6+ messages in thread From: Andres Freund @ 2022-11-19 21:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on 32bit ProcSleep() used a PGPROC* variable to point to PROC_QUEUE->links.next, because that does "the right thing" with SHMQueueInsertBefore(). While that largely works, it's certainly not correct and unnecessary - we can just use SHM_QUEUE* to point to the insertion point. Noticed when testing a 32bit of postgres with undefined behavior sanitizer. UBSan noticed that sometimes the supposed PGPROC wasn't sufficiently aligned (required since 46d6e5f5679, ensured indirectly, via ShmemAllocRaw() guaranteeing cacheline alignment). For now fix this by using a SHM_QUEUE* for the insertion point. Subsequently we should replace all the use of PROC_QUEUE and SHM_QUEUE with ilist.h, but that's a larger change that we don't want to backpatch. Backpatch to all supported versions - it's useful to be able to run postgres under UBSan. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/20221117014230.op5kmgypdv2dtqsf@awork3.anarazel.de Backpatch: 11- Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a0d35ebcc570265405a293e509dccbdf0fd5ee45 Modified Files -------------- src/backend/storage/lmgr/proc.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on @ 2022-11-19 21:56 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 6+ messages in thread From: Andres Freund @ 2022-11-19 21:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on 32bit ProcSleep() used a PGPROC* variable to point to PROC_QUEUE->links.next, because that does "the right thing" with SHMQueueInsertBefore(). While that largely works, it's certainly not correct and unnecessary - we can just use SHM_QUEUE* to point to the insertion point. Noticed when testing a 32bit of postgres with undefined behavior sanitizer. UBSan noticed that sometimes the supposed PGPROC wasn't sufficiently aligned (required since 46d6e5f5679, ensured indirectly, via ShmemAllocRaw() guaranteeing cacheline alignment). For now fix this by using a SHM_QUEUE* for the insertion point. Subsequently we should replace all the use of PROC_QUEUE and SHM_QUEUE with ilist.h, but that's a larger change that we don't want to backpatch. Backpatch to all supported versions - it's useful to be able to run postgres under UBSan. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/20221117014230.op5kmgypdv2dtqsf@awork3.anarazel.de Backpatch: 11- Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/140c80372327fb7723859d982b3efda754b266a7 Modified Files -------------- src/backend/storage/lmgr/proc.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on @ 2022-11-19 21:56 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 6+ messages in thread From: Andres Freund @ 2022-11-19 21:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on 32bit ProcSleep() used a PGPROC* variable to point to PROC_QUEUE->links.next, because that does "the right thing" with SHMQueueInsertBefore(). While that largely works, it's certainly not correct and unnecessary - we can just use SHM_QUEUE* to point to the insertion point. Noticed when testing a 32bit of postgres with undefined behavior sanitizer. UBSan noticed that sometimes the supposed PGPROC wasn't sufficiently aligned (required since 46d6e5f5679, ensured indirectly, via ShmemAllocRaw() guaranteeing cacheline alignment). For now fix this by using a SHM_QUEUE* for the insertion point. Subsequently we should replace all the use of PROC_QUEUE and SHM_QUEUE with ilist.h, but that's a larger change that we don't want to backpatch. Backpatch to all supported versions - it's useful to be able to run postgres under UBSan. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/20221117014230.op5kmgypdv2dtqsf@awork3.anarazel.de Backpatch: 11- Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/8c954168cff4630ae94df649b458f4a3aad6d9a7 Modified Files -------------- src/backend/storage/lmgr/proc.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on @ 2022-11-19 21:56 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 6+ messages in thread From: Andres Freund @ 2022-11-19 21:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on 32bit ProcSleep() used a PGPROC* variable to point to PROC_QUEUE->links.next, because that does "the right thing" with SHMQueueInsertBefore(). While that largely works, it's certainly not correct and unnecessary - we can just use SHM_QUEUE* to point to the insertion point. Noticed when testing a 32bit of postgres with undefined behavior sanitizer. UBSan noticed that sometimes the supposed PGPROC wasn't sufficiently aligned (required since 46d6e5f5679, ensured indirectly, via ShmemAllocRaw() guaranteeing cacheline alignment). For now fix this by using a SHM_QUEUE* for the insertion point. Subsequently we should replace all the use of PROC_QUEUE and SHM_QUEUE with ilist.h, but that's a larger change that we don't want to backpatch. Backpatch to all supported versions - it's useful to be able to run postgres under UBSan. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/20221117014230.op5kmgypdv2dtqsf@awork3.anarazel.de Backpatch: 11- Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/4cbcb7ed85b0e235300059dbbbdb83aec4ec8eaf Modified Files -------------- src/backend/storage/lmgr/proc.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2022-11-19 21:56 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-11-19 21:56 pgsql: Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on Andres Freund <andres@anarazel.de> 2022-11-19 21:56 pgsql: Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on Andres Freund <andres@anarazel.de> 2022-11-19 21:56 pgsql: Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on Andres Freund <andres@anarazel.de> 2022-11-19 21:56 pgsql: Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on Andres Freund <andres@anarazel.de> 2022-11-19 21:56 pgsql: Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on Andres Freund <andres@anarazel.de> 2022-11-19 21:56 pgsql: Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on Andres Freund <andres@anarazel.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox