mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
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
This commit is contained in:
@@ -108,5 +108,6 @@ extern bool reindex_relation(Oid relid, int flags);
|
||||
|
||||
extern bool ReindexIsProcessingHeap(Oid heapOid);
|
||||
extern bool ReindexIsProcessingIndex(Oid indexOid);
|
||||
extern Oid IndexGetRelation(Oid indexId);
|
||||
|
||||
#endif /* INDEX_H */
|
||||
|
@@ -242,6 +242,7 @@ extern char *ChooseConstraintName(const char *name1, const char *name2,
|
||||
|
||||
extern void AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
|
||||
Oid newNspId, bool isType, ObjectAddresses *objsMoved);
|
||||
extern void get_constraint_relation_oids(Oid constraint_oid, Oid *conrelid, Oid *confrelid);
|
||||
extern Oid get_constraint_oid(Oid relid, const char *conname, bool missing_ok);
|
||||
|
||||
extern bool check_functional_grouping(Oid relid,
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
/* commands/indexcmds.c */
|
||||
extern void DefineIndex(RangeVar *heapRelation,
|
||||
extern void DefineIndex(Oid relationId,
|
||||
char *indexRelationName,
|
||||
Oid indexRelationId,
|
||||
char *accessMethodName,
|
||||
|
@@ -25,7 +25,7 @@ extern Oid DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId);
|
||||
|
||||
extern void RemoveRelations(DropStmt *drop);
|
||||
|
||||
extern void AlterTable(AlterTableStmt *stmt);
|
||||
extern void AlterTable(Oid relid, AlterTableStmt *stmt);
|
||||
|
||||
extern LOCKMODE AlterTableGetLockLevel(List *cmds);
|
||||
|
||||
|
@@ -109,7 +109,7 @@ extern PGDLLIMPORT int SessionReplicationRole;
|
||||
#define TRIGGER_DISABLED 'D'
|
||||
|
||||
extern Oid CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
||||
Oid constraintOid, Oid indexOid,
|
||||
Oid relOid, Oid refRelOid, Oid constraintOid, Oid indexOid,
|
||||
bool isInternal);
|
||||
|
||||
extern void DropTrigger(Oid relid, const char *trigname,
|
||||
|
@@ -1553,6 +1553,8 @@ typedef struct Constraint
|
||||
char fk_del_action; /* ON DELETE action */
|
||||
bool skip_validation; /* skip validation of existing rows? */
|
||||
bool initially_valid; /* mark the new constraint as valid? */
|
||||
|
||||
Oid old_pktable_oid; /* pg_constraint.confrelid of my former self */
|
||||
} Constraint;
|
||||
|
||||
/* ----------------------
|
||||
|
@@ -18,9 +18,10 @@
|
||||
|
||||
|
||||
extern List *transformCreateStmt(CreateStmt *stmt, const char *queryString);
|
||||
extern List *transformAlterTableStmt(AlterTableStmt *stmt,
|
||||
extern List *transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
||||
const char *queryString);
|
||||
extern IndexStmt *transformIndexStmt(IndexStmt *stmt, const char *queryString);
|
||||
extern IndexStmt *transformIndexStmt(Oid relid, IndexStmt *stmt,
|
||||
const char *queryString);
|
||||
extern void transformRuleStmt(RuleStmt *stmt, const char *queryString,
|
||||
List **actions, Node **whereClause);
|
||||
extern List *transformCreateSchemaStmt(CreateSchemaStmt *stmt);
|
||||
|
@@ -40,6 +40,6 @@ extern LogStmtLevel GetCommandLogLevel(Node *parsetree);
|
||||
|
||||
extern bool CommandIsReadOnly(Node *parsetree);
|
||||
|
||||
extern void CheckRelationOwnership(RangeVar *rel, bool noCatalogs);
|
||||
extern void CheckRelationOwnership(Oid relOid, bool noCatalogs);
|
||||
|
||||
#endif /* UTILITY_H */
|
||||
|
Reference in New Issue
Block a user