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

Commitb53c7c3

Browse files
committed
Ignore SECURITY DEFINER and SET attributes for a PL's call handler.
It's not very sensible to set such attributes on a handler function;but if one were to do so, fmgr.c went into infinite recursion becauseit would call fmgr_security_definer instead of the handler function proper.There is no way for fmgr_security_definer to know that it ought to call thehandler and not the original function referenced by the FmgrInfo's fn_oid,so it tries to do the latter, causing the whole process to start overagain.Ordinarily such misconfiguration of a procedural language's handler couldbe written off as superuser error. However, because we allow non-superuserdatabase owners to create procedural languages and the handler for such alanguage becomes owned by the database owner, it is possible for a databaseowner to crash the backend, which ideally shouldn't be possible withoutsuperuser privileges. In 9.2 and up we will adjust things so that thehandler functions are always owned by superusers, but in existing branchesthis is a minor security fix.Problem noted by Noah Misch (after several of us had failed to detectit :-(). This isCVE-2012-2655.
1 parent9b0875a commitb53c7c3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

‎src/backend/utils/fmgr/fmgr.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fmgr_lookupByName(const char *name)
153153
void
154154
fmgr_info(OidfunctionId,FmgrInfo*finfo)
155155
{
156-
fmgr_info_cxt(functionId,finfo,CurrentMemoryContext);
156+
fmgr_info_cxt_security(functionId,finfo,CurrentMemoryContext, false);
157157
}
158158

159159
/*
@@ -168,7 +168,7 @@ fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
168168

169169
/*
170170
* This one does the actual work. ignore_security is ordinarily false
171-
* but is set to trueby fmgr_security_definer to avoid recursion.
171+
* but is set to truewhen we need to avoid recursion.
172172
*/
173173
staticvoid
174174
fmgr_info_cxt_security(OidfunctionId,FmgrInfo*finfo,MemoryContextmcxt,
@@ -218,7 +218,7 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt,
218218
/*
219219
* If it has prosecdef set, or non-null proconfig, use
220220
* fmgr_security_definer call handler --- unless we are being called again
221-
* by fmgr_security_definer.
221+
* by fmgr_security_definer or fmgr_info_other_lang.
222222
*
223223
* When using fmgr_security_definer, function stats tracking is always
224224
* disabled at the outer level, and instead we set the flag properly in
@@ -399,7 +399,13 @@ fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
399399
elog(ERROR,"cache lookup failed for language %u",language);
400400
languageStruct= (Form_pg_language)GETSTRUCT(languageTuple);
401401

402-
fmgr_info(languageStruct->lanplcallfoid,&plfinfo);
402+
/*
403+
* Look up the language's call handler function, ignoring any attributes
404+
* that would normally cause insertion of fmgr_security_definer. We
405+
* need to get back a bare pointer to the actual C-language function.
406+
*/
407+
fmgr_info_cxt_security(languageStruct->lanplcallfoid,&plfinfo,
408+
CurrentMemoryContext, true);
403409
finfo->fn_addr=plfinfo.fn_addr;
404410

405411
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp