pgsql: Add defenses against running with a wrong selection of LOBLKSIZE - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Add defenses against running with a wrong selection of LOBLKSIZE
Date
Msg-id E1WsZds-0000Iq-Rf@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Add defenses against running with a wrong selection of LOBLKSIZE.

It's critical that the backend's idea of LOBLKSIZE match the way data has
actually been divided up in pg_largeobject.  While we don't provide any
direct way to adjust that value, doing so is a one-line source code change
and various people have expressed interest recently in changing it.  So,
just as with TOAST_MAX_CHUNK_SIZE, it seems prudent to record the value in
pg_control and cross-check that the backend's compiled-in setting matches
the on-disk data.

Also tweak the code in inv_api.c so that fetches from pg_largeobject
explicitly verify that the length of the data field is not more than
LOBLKSIZE.  Formerly we just had Asserts() for that, which is no protection
at all in production builds.  In some of the call sites an overlength data
value would translate directly to a security-relevant stack clobber, so it
seems worth one extra runtime comparison to be sure.

In the back branches, we can't change the contents of pg_control; but we
can still make the extra checks in inv_api.c, which will offer some amount
of protection against running with the wrong value of LOBLKSIZE.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/c9f4618e5b0cee1b125e59b947c9f4b3fe1887d2

Modified Files
--------------
src/backend/storage/large_object/inv_api.c |   84 +++++++++++++---------------
1 file changed, 39 insertions(+), 45 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Add defenses against running with a wrong selection of LOBLKSIZE
Next
From: Tom Lane
Date:
Subject: pgsql: Add defenses against running with a wrong selection of LOBLKSIZE