Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3e13384

Browse files
committed
Add missing checks to some of pageinspect's BRIN functions
brin_page_type() and brin_metapage_info() did not enforce being calledby superuser, like other pageinspect functions that take bytea do.Since they don't verify the passed page thoroughly, it is possible touse them to read the server memory with a carefully crafted bytea value,up to a file kilobytes from where the input bytea is located.Have them throw errors if called by a non-superuser.Report and initial patch: Andreas SeltenreichSecurity:CVE-2016-3065
1 parent86ebf30 commit3e13384

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

‎contrib/pageinspect/brinfuncs.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,23 @@ brin_page_type(PG_FUNCTION_ARGS)
4646
{
4747
bytea*raw_page=PG_GETARG_BYTEA_P(0);
4848
Pagepage=VARDATA(raw_page);
49+
intraw_page_size;
4950
char*type;
5051

52+
if (!superuser())
53+
ereport(ERROR,
54+
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
55+
(errmsg("must be superuser to use raw page functions"))));
56+
57+
raw_page_size=VARSIZE(raw_page)-VARHDRSZ;
58+
59+
if (raw_page_size!=BLCKSZ)
60+
ereport(ERROR,
61+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
62+
errmsg("input page too small"),
63+
errdetail("Expected size %d, got %d",
64+
BLCKSZ,raw_page_size)));
65+
5166
switch (BrinPageType(page))
5267
{
5368
caseBRIN_PAGETYPE_META:
@@ -79,11 +94,12 @@ verify_brin_page(bytea *raw_page, uint16 type, const char *strtype)
7994

8095
raw_page_size=VARSIZE(raw_page)-VARHDRSZ;
8196

82-
if (raw_page_size<SizeOfPageHeaderData)
97+
if (raw_page_size!=BLCKSZ)
8398
ereport(ERROR,
8499
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
85100
errmsg("input page too small"),
86-
errdetail("Expected size %d, got %d",raw_page_size,BLCKSZ)));
101+
errdetail("Expected size %d, got %d",
102+
BLCKSZ,raw_page_size)));
87103

88104
page=VARDATA(raw_page);
89105

@@ -316,6 +332,11 @@ brin_metapage_info(PG_FUNCTION_ARGS)
316332
boolnulls[4];
317333
HeapTuplehtup;
318334

335+
if (!superuser())
336+
ereport(ERROR,
337+
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
338+
(errmsg("must be superuser to use raw page functions"))));
339+
319340
page=verify_brin_page(raw_page,BRIN_PAGETYPE_META,"metapage");
320341

321342
/* Build a tuple descriptor for our result type */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp