postgresql/src/include
Tom Lane b69af3dda2 Harden _int_matchsel() against being attached to the wrong operator.
While the preceding commit prevented such attachments from occurring
in future, this one aims to prevent further abuse of any already-
created operator that exposes _int_matchsel to the wrong data types.
(No other contrib module has a vulnerable selectivity estimator.)

We need only check that the Const we've found in the query is indeed
of the type we expect (query_int), but there's a difficulty: as an
extension type, query_int doesn't have a fixed OID that we could
hard-code into the estimator.

Therefore, the bulk of this patch consists of infrastructure to let
an extension function securely look up the OID of a datatype
belonging to the same extension.  (Extension authors have requested
such functionality before, so we anticipate that this code will
have additional non-security uses, and may soon be extended to allow
looking up other kinds of SQL objects.)

This is done by first finding the extension that owns the calling
function (there can be only one), and then thumbing through the
objects owned by that extension to find a type that has the desired
name.  This is relatively expensive, especially for large extensions,
so a simple cache is put in front of these lookups.

Reported-by: Daniel Firer as part of zeroday.cloud
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Noah Misch <noah@leadboat.com>
Security: CVE-2026-2004
Backpatch-through: 14
2026-02-09 10:14:22 -05:00
..
access Prevent invalidation of newly synced replication slots. 2026-01-27 05:45:25 +00:00
archive Update copyright for 2025 2025-01-01 11:21:55 -05:00
backup Update copyright for 2025 2025-01-01 11:21:55 -05:00
bootstrap pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
catalog Harden _int_matchsel() against being attached to the wrong operator. 2026-02-09 10:14:22 -05:00
commands Harden _int_matchsel() against being attached to the wrong operator. 2026-02-09 10:14:22 -05:00
common Use 'void *' for arbitrary buffers, 'uint8 *' for byte arrays 2025-05-08 22:01:25 +03:00
datatype Avoid using timezone Asia/Manila in regression tests. 2025-01-20 15:47:53 -05:00
executor Fix EvalPlanQual handling of foreign/custom joins in ExecScanFetch. 2025-10-15 17:15:01 +09:00
fe_utils Remove inappropriate inclusions of c.h and postgres_fe.h. 2025-04-27 16:58:57 -04:00
foreign Update copyright for 2025 2025-01-01 11:21:55 -05:00
jit Don't use double-quotes in #include's of system headers, redux. 2025-04-27 13:23:19 -04:00
lib Fix reset of incorrect hash iterator in GROUPING SETS queries 2025-10-18 16:07:41 +13:00
libpq Use 'void *' for arbitrary buffers, 'uint8 *' for byte arrays 2025-05-08 22:01:25 +03:00
mb Replace pg_mblen() with bounds-checked versions. 2026-02-09 12:43:42 +13:00
nodes Fix query jumbling with GROUP BY clauses 2026-01-14 08:44:52 +09:00
optimizer Strip PlaceHolderVars from index operands 2025-12-29 11:43:06 +09:00
parser Revert support for improved tracking of nested queries 2025-06-12 10:08:55 +09:00
partitioning Fix incorrect #endif comment 2025-03-10 13:36:04 +13:00
pch Update copyright for 2025 2025-01-01 11:21:55 -05:00
port Fix O_CLOEXEC flag handling in Windows port. 2025-12-10 09:05:21 +13:00
portability Update copyright for 2025 2025-01-01 11:21:55 -05:00
postmaster Fix incorrect const qualifier 2025-09-16 07:23:50 +02:00
regex Update copyright for 2025 2025-01-01 11:21:55 -05:00
replication Make invalid primary_slot_name follow standard GUC error reporting. 2025-10-22 20:10:58 +09:00
rewrite Refactor ChangeVarNodesExtended() using the custom callback 2025-05-07 11:10:16 +03:00
snowball Update to latest Snowball sources. 2025-02-18 21:13:54 -05:00
statistics Fix redefinition of typedef RangeVar. 2025-10-15 13:14:00 -05:00
storage Add file_extend_method=posix_fallocate,write_zeros. 2026-02-06 17:38:39 +13:00
tcop Sync typedefs.list with the buildfarm. 2025-06-15 13:04:24 -04:00
tsearch Replace pg_mblen() with bounds-checked versions. 2026-02-09 12:43:42 +13:00
utils Guard against unexpected dimensions of oidvector/int2vector. 2026-02-09 09:57:44 -05:00
.gitignore Use <stdint.h> and <inttypes.h> for c.h integers. 2024-12-04 15:05:38 +13:00
c.h Remove INT64_HEX_FORMAT and UINT64_HEX_FORMAT 2025-08-06 10:58:06 +02:00
fmgr.h Avoid mixing designated and non-designated field initializers. 2025-03-27 11:06:30 -04:00
funcapi.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
getopt_long.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
Makefile Fix build inconsistency due to the generation of wait-event code 2026-02-02 08:02:59 +09:00
meson.build Update copyright for 2025 2025-01-01 11:21:55 -05:00
miscadmin.h Avoid mixing void and integer in a conditional expression. 2025-11-02 12:31:01 -05:00
pg_config.h.in aio: Combine io_uring memory mappings, if supported 2025-07-07 21:04:03 -04:00
pg_config_manual.h Avoid invalidating all RelationSyncCache entries on publication rename. 2025-03-13 09:16:33 +05:30
pg_getopt.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
pg_trace.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
pgstat.h Don't include execnodes.h in replication/conflict.h 2025-09-25 14:52:19 +02:00
pgtar.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
pgtime.h Seek zone abbreviations in the IANA data before timezone_abbreviations. 2025-01-16 14:11:19 -05:00
port.h Fix O_CLOEXEC flag handling in Windows port. 2025-12-10 09:05:21 +13:00
postgres.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
postgres_ext.h Move pg_int64 back to postgres_ext.h 2025-09-16 10:48:44 +02:00
postgres_fe.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
varatt.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
windowapi.h Update copyright for 2025 2025-01-01 11:21:55 -05:00