Skip to content

Commit a7812eb

Browse files
committed
Fix Windows-only postmaster code to reject a connection request and continue,
rather than elog(FATAL), when there is no more room in ShmemBackendArray. This is a security issue since too many connection requests arriving close together could cause the postmaster to shut down, resulting in denial of service. Reported by Yoshiyuki Asaba, fixed by Magnus Hagander.
1 parent bf7faa7 commit a7812eb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.478 2006/01/05 10:07:45 petere Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.479 2006/01/06 02:58:25 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -147,7 +147,11 @@ typedef struct bkend
147147
static Dllist *BackendList;
148148

149149
#ifdef EXEC_BACKEND
150-
#define NUM_BACKENDARRAY_ELEMS (2*MaxBackends)
150+
/*
151+
* Number of entries in the backend table. Twice the number of backends,
152+
* plus four other subprocesses (stats, bgwriter, autovac, logger).
153+
*/
154+
#define NUM_BACKENDARRAY_ELEMS (2*MaxBackends + 4)
151155
static Backend *ShmemBackendArray;
152156
#endif
153157

@@ -3083,6 +3087,15 @@ internal_forkexec(int argc, char *argv[], Port *port)
30833087
Assert(strncmp(argv[1], "-fork", 5) == 0);
30843088
Assert(argv[2] == NULL);
30853089

3090+
/* Verify that there is room in the child list */
3091+
if (win32_numChildren >= NUM_BACKENDARRAY_ELEMS)
3092+
{
3093+
elog(LOG, "no room for child entry in backend list");
3094+
/* Report same error as for a fork failure on Unix */
3095+
errno = EAGAIN;
3096+
return -1;
3097+
}
3098+
30863099
/* Set up shared memory for parameter passing */
30873100
ZeroMemory(&sa, sizeof(sa));
30883101
sa.nLength = sizeof(sa);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy