postgresql/src
Michael Paquier a0b0136259 Avoid memory size overflow when allocating backend activity buffer
The code in charge of copying the contents of PgBackendStatus to local
memory could fail on memory allocation because of an overflow on the
amount of memory to use.  The overflow can happen when combining a high
value track_activity_query_size (max at 1MB) with a large
max_connections, when both multiplied get higher than INT32_MAX as both
parameters treated as signed integers.  This could for example trigger
with the following functions, all calling pgstat_read_current_status():
- pg_stat_get_backend_subxact()
- pg_stat_get_backend_idset()
- pg_stat_get_progress_info()
- pg_stat_get_activity()
- pg_stat_get_db_numbackends()

The change to use MemoryContextAllocHuge() has been introduced in
8d0ddccec6, so backpatch down to 12.

Author: Jakub Wartak
Discussion: https://postgr.es/m/CAKZiRmw8QSNVw2qNK-dznsatQqz+9DkCquxP0GHbbv1jMkGHMA@mail.gmail.com
Backpatch-through: 12
2023-10-03 15:37:23 +09:00
..
backend Avoid memory size overflow when allocating backend activity buffer 2023-10-03 15:37:23 +09:00
bin Fix omission of column-level privileges in selective pg_restore. 2023-10-02 13:27:51 -04:00
common Fix JSON error reporting for many cases of erroneous string values. 2023-03-13 15:19:00 -04:00
fe_utils Clean up assorted failures under clang's -fsanitize=undefined checks. 2022-03-03 18:13:24 -05:00
include Fix btmarkpos/btrestrpos array key wraparound bug. 2023-09-28 16:29:27 -07:00
interfaces Translation updates 2023-05-08 14:36:07 +02:00
makefiles Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
pl Remove environment sensitivity in pl/tcl regression test. 2023-09-29 20:20:57 -04: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 Fix edge-case for xl_tot_len broken by bae868ca. 2023-09-26 10:54:47 +13:00
timezone Update time zone data files to tzdata release 2023c. 2023-04-18 14:46:39 -04:00
tools Fix exception safety bug in typcache.c. 2023-09-13 14:48:00 +12:00
tutorial Doc: sync src/tutorial/basics.source with SGML documentation. 2022-11-19 13:09:14 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Suppress macOS warnings about duplicate libraries in link commands. 2023-09-29 14:07:30 -04:00
Makefile.shlib Stop using "-multiply_defined suppress" on macOS. 2023-09-26 21:06:21 -04:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:04:20 +02:00