Avoid out-of-bounds reads in parallel btree scans with array keys.

The backends participating in a parallel btree scan with array
keys (e.g., "= ANY (...)" quals) hand their positions in the arrays
back and forth through shared memory, on the assumption that they
all built the same arrays.  Nothing verifies that, so a function
mislabeled as PARALLEL SAFE or STABLE can leave the backends with
different arrays, after which a backend might read past the end of
its own array or, if the backends don't even agree on how many
arrays there are, read the saved positions from the wrong place.
To fix, save the number of arrays along with the positions, refuse
to restore anything when it doesn't match, and reject a saved
element number that isn't in range for our own array.  v17 saves
only element numbers, so it just needs the range check.

Reported-by: Claude and Ada Logics
Author: Nathan Bossart <[email protected]>
Reviewed-by: Peter Geoghegan <[email protected]>
Reviewed-by: Bharath Rupireddy <[email protected]>
Security: CVE-2026-116333
Backpatch-through: 17

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1dfde5b374b0b3554f3370913391b8d22ff81d29
Author: Nathan Bossart <[email protected]>

Modified Files
--------------
src/backend/access/nbtree/nbtree.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)

Reply via email to