Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas2014-02-17 14:33:31 +0000
committerRobert Haas2014-02-17 14:33:31 +0000
commit5f173040e324f6c2eebb90d86cf1b0cdb5890f0a (patch)
tree9c3d313acb74c092bc2664b862720f340460bb80 /src/backend/bootstrap
parent540b4e5bc85f7e44842493a810b04a84881db20f (diff)
Avoid repeated name lookups during table and index DDL.
If the name lookups come to different conclusions due to concurrent activity, we might perform some parts of the DDL on a different table than other parts. At least in the case of CREATE INDEX, this can be used to cause the permissions checks to be performed against a different table than the index creation, allowing for a privilege escalation attack. This changes the calling convention for DefineIndex, CreateTrigger, transformIndexStmt, transformAlterTableStmt, CheckIndexCompatible (in 9.2 and newer), and AlterTable (in 9.1 and older). In addition, CheckRelationOwnership is removed in 9.2 and newer and the calling convention is changed in older branches. A field has also been added to the Constraint node (FkConstraint in 8.4). Third-party code calling these functions or using the Constraint node will require updating. Report by Andres Freund. Patch by Robert Haas and Andres Freund, reviewed by Tom Lane. Security: CVE-2014-0062
Diffstat (limited to 'src/backend/bootstrap')
-rw-r--r--src/backend/bootstrap/bootparse.y17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/backend/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y
index d080297512d..5585e9b6b9b 100644
--- a/src/backend/bootstrap/bootparse.y
+++ b/src/backend/bootstrap/bootparse.y
@@ -27,6 +27,7 @@
#include "bootstrap/bootstrap.h"
#include "catalog/catalog.h"
#include "catalog/heap.h"
+#include "catalog/namespace.h"
#include "catalog/pg_am.h"
#include "catalog/pg_attribute.h"
#include "catalog/pg_authid.h"
@@ -282,6 +283,7 @@ Boot_DeclareIndexStmt:
XDECLARE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN
{
IndexStmt *stmt = makeNode(IndexStmt);
+ Oid relationId;
do_start();
@@ -303,7 +305,12 @@ Boot_DeclareIndexStmt:
stmt->initdeferred = false;
stmt->concurrent = false;
- DefineIndex(stmt,
+ /* locks and races need not concern us in bootstrap mode */
+ relationId = RangeVarGetRelid(stmt->relation, NoLock,
+ false);
+
+ DefineIndex(relationId,
+ stmt,
$4,
false,
false,
@@ -317,6 +324,7 @@ Boot_DeclareUniqueIndexStmt:
XDECLARE UNIQUE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN
{
IndexStmt *stmt = makeNode(IndexStmt);
+ Oid relationId;
do_start();
@@ -338,7 +346,12 @@ Boot_DeclareUniqueIndexStmt:
stmt->initdeferred = false;
stmt->concurrent = false;
- DefineIndex(stmt,
+ /* locks and races need not concern us in bootstrap mode */
+ relationId = RangeVarGetRelid(stmt->relation, NoLock,
+ false);
+
+ DefineIndex(relationId,
+ stmt,
$5,
false,
false,