]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix two violations of the ResourceOwnerEnlarge/Remember protocol.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 8 Nov 2017 21:50:12 +0000 (16:50 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 8 Nov 2017 21:50:12 +0000 (16:50 -0500)
commitc5269472ea9bb4a6fbb8a0510f7d676d725933ab
tree8b6ca7067c88b8b033e7cbc5b5e6b893303dce6a
parent2eb4a831e5fb5d8fc17e13aea56e04af3efe27b4
Fix two violations of the ResourceOwnerEnlarge/Remember protocol.

The point of having separate ResourceOwnerEnlargeFoo and
ResourceOwnerRememberFoo functions is so that resource allocation
can happen in between.  Doing it in some other order is just wrong.

OpenTemporaryFile() did open(), enlarge, remember, which would leak the
open file if the enlarge step ran out of memory.  Because fd.c has its own
layer of resource-remembering, the consequences look like they'd be limited
to an intratransaction FD leak, but it's still not good.

IncrBufferRefCount() did enlarge, remember, incr-refcount, which would blow
up if the incr-refcount step ever failed.  It was safe enough when written,
but since the introduction of PrivateRefCountHash, I think the assumption
that no error could happen there is pretty shaky.

The odds of real problems from either bug are probably small, but still,
back-patch to supported branches.

Thomas Munro and Tom Lane, per a comment from Andres Freund
src/backend/storage/buffer/bufmgr.c
src/backend/storage/file/fd.c