postgresql/src
Andres Freund c13667b518 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 46d6e5f567, 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-
2022-11-19 12:36:33 -08:00
..
backend Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on 32bit 2022-11-19 12:36:33 -08:00
bin pg_dump: avoid unsafe function calls in getPolicies(). 2022-11-19 12:00:27 -05:00
common Change some errdetail() to errdetail_internal() 2022-09-28 17:14:53 +02:00
fe_utils Clean up assorted failures under clang's -fsanitize=undefined checks. 2022-03-03 18:13:24 -05:00
include Replace RelationOpenSmgr() with RelationGetSmgr(). 2022-11-17 16:54:30 -05:00
interfaces Translation updates 2022-11-07 13:57:17 +01:00
makefiles Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
pl Translation updates 2022-11-07 13:57:17 +01:00
port Re-allow building on Microsoft Visual Studio 2013. 2022-11-10 10:23:49 -05:00
template On NetBSD, force dynamic symbol resolution at postmaster start. 2022-08-30 17:29:08 -04:00
test Account for IPC::Run::result() Windows behavior change. 2022-11-17 07:37:02 -08:00
timezone Update time zone data files to tzdata release 2022f. 2022-11-01 17:09:04 -04:00
tools Improve setup of environment values for commands in MSVC's vcregress.pl 2022-05-11 10:22:34 +09:00
tutorial Doc: sync src/tutorial/basics.source with SGML documentation. 2022-11-19 13:09:14 -05:00
.gitignore
DEVELOPERS
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Fix prove_installcheck to use correct paths when used with PGXS 2021-07-01 08:46:38 -04:00
Makefile.shlib AIX: Fix missing libpq symbols by respecting SHLIB_EXPORTS. 2021-09-06 11:28:02 -07:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:04:20 +02:00