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_17_STABLE

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

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

Reply via email to