pgsql: Repair failure to check that a table is still compatible with a - Mailing list pgsql-committers

From tgl@postgresql.org (Tom Lane)
Subject pgsql: Repair failure to check that a table is still compatible with a
Date
Msg-id 20070202000744.B74779FB26A@postgresql.org
Whole thread Raw
List pgsql-committers
Log Message:
-----------
Repair failure to check that a table is still compatible with a previously
made query plan.  Use of ALTER COLUMN TYPE creates a hazard for cached
query plans: they could contain Vars that claim a column has a different
type than it now has.  Fix this by checking during plan startup that Vars
at relation scan level match the current relation tuple descriptor.  Since
at that point we already have at least AccessShareLock, we can be sure the
column type will not change underneath us later in the query.  However,
since a backend's locks do not conflict against itself, there is still a
hole for an attacker to exploit: he could try to execute ALTER COLUMN TYPE
while a query is in progress in the current backend.  Seal that hole by
rejecting ALTER TABLE whenever the target relation is already open in
the current backend.

This is a significant security hole: not only can one trivially crash the
backend, but with appropriate misuse of pass-by-reference datatypes it is
possible to read out arbitrary locations in the server process's memory,
which could allow retrieving database content the user should not be able
to see.  Our thanks to Jeff Trout for the initial report.

Security: CVE-2007-0556

Tags:
----
REL8_1_STABLE

Modified Files:
--------------
    pgsql/src/backend/commands:
        tablecmds.c (r1.174.2.3 -> r1.174.2.4)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/tablecmds.c.diff?r1=1.174.2.3&r2=1.174.2.4)
    pgsql/src/backend/executor:
        execQual.c (r1.183.2.4 -> r1.183.2.5)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/execQual.c.diff?r1=1.183.2.4&r2=1.183.2.5)
        execScan.c (r1.37.2.1 -> r1.37.2.2)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/execScan.c.diff?r1=1.37.2.1&r2=1.37.2.2)
        execUtils.c (r1.126.2.3 -> r1.126.2.4)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/execUtils.c.diff?r1=1.126.2.3&r2=1.126.2.4)
        nodeAgg.c (r1.135.2.1 -> r1.135.2.2)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeAgg.c.diff?r1=1.135.2.1&r2=1.135.2.2)
        nodeGroup.c (r1.62 -> r1.62.2.1)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeGroup.c.diff?r1=1.62&r2=1.62.2.1)
        nodeHashjoin.c (r1.75.2.3 -> r1.75.2.4)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeHashjoin.c.diff?r1=1.75.2.3&r2=1.75.2.4)
        nodeMergejoin.c (r1.75.2.2 -> r1.75.2.3)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeMergejoin.c.diff?r1=1.75.2.2&r2=1.75.2.3)
        nodeNestloop.c (r1.39.2.1 -> r1.39.2.2)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeNestloop.c.diff?r1=1.39.2.1&r2=1.39.2.2)
        nodeResult.c (r1.32.2.1 -> r1.32.2.2)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeResult.c.diff?r1=1.32.2.1&r2=1.32.2.2)
        nodeSubplan.c (r1.70.2.1 -> r1.70.2.2)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeSubplan.c.diff?r1=1.70.2.1&r2=1.70.2.2)
    pgsql/src/include/executor:
        executor.h (r1.120.2.2 -> r1.120.2.3)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/executor/executor.h.diff?r1=1.120.2.2&r2=1.120.2.3)

pgsql-committers by date:

Previous
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Repair failure to check that a table is still compatible with a
Next
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Repair insufficiently careful type checking for SQL-language