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 1wVPUE-001wRY-37 for pgsql-bugs@arkaria.postgresql.org; Fri, 05 Jun 2026 08:01: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 1wVPUD-00AsfP-2j for pgsql-bugs@arkaria.postgresql.org; Fri, 05 Jun 2026 08:01:01 +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 1wVPUD-00AsfH-1t for pgsql-bugs@lists.postgresql.org; Fri, 05 Jun 2026 08:01:01 +0000 Received: from mail-dl1-x1235.google.com ([2607:f8b0:4864:20::1235]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wVPUB-00000001Nu5-1ckb for pgsql-bugs@postgresql.org; Fri, 05 Jun 2026 08:01:01 +0000 Received: by mail-dl1-x1235.google.com with SMTP id a92af1059eb24-137335bc3caso2023298c88.0 for ; Fri, 05 Jun 2026 01:00:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780646457; cv=none; d=google.com; s=arc-20240605; b=SGCSXp5qv5crKenp2z/KS4MeC4TnIMn4NO/ltX/KtqtNQydese+DCKr6t62fU5s62G kuGpKaHm//TBxM/DFa+F1bWEs/xkbNR6fvYxtaGpDi/q0RujnZMBDtpcOm8kXRQXBO8x JTishPXJtOO9GFknZA+jD4i2lwllHxiYo6YQQwKUqzvZqr9EADpviGU2bzr5gYo18HsA eAco1T3hVtDXIl5/NRadpjpuOSReWgQCyqikGKcDJs5hSYBIoiqpt/LzeErFPJ/C88X5 5W/EhbecaFsDquWA1OkutVxvB0oNqDE/hwnUlwj3bQrXCnnoq94VDDElwjYzrzL88NU9 VLlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=VUoRf71kuB7I15fGX7368Mh90WxDaXIoXoXn04xRBHo=; fh=uyfHfEb8LzpbtgxyCZ4bfbg+GBeMDkgENsU6bjyBKVQ=; b=IxfcylBLeNg8g34zKwdT+bTGzoLOvkSPzTnj90WzExZ2qwfeOzQP2W2W2a07ExM6uu Rbx21JXZdVn2+A74Npf+rIwbXuz12tbLT8/ekwEAbM3t53s5v8qq8iGvNmf1bHpx+u3Q lrPHSksdkn29TV34yusq1/22R8Swd7WoBt1tSW+nlXwW1o+PqofAbyPmOUxrted/czLr ojkc7J9EsFxiQBAqjtD+beAkmn4MLOiLRfu6iPY6XBXFpYFA/qSil66GhaNOeayXTf0J +PnCpt132Gx5S3N48s09ymyuxcPGq5kEHfurBhYn3zX5YRFbdplkco9SH91X7yBwwlTZ P/aA==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780646457; x=1781251257; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VUoRf71kuB7I15fGX7368Mh90WxDaXIoXoXn04xRBHo=; b=N6XXafwJdQ1BPfcW2utTcmQiN5xYIA35sLmi5/uCCuMZs8VBBC97zBRl/3dAVL0wo/ hS8+zApBDKC3kJg43FHiHRbQN2a6RcI9Ce+ndFfD+Kt7L61y8EBv2NoHa0TtZeCj8AU+ Cai2jPqKw0hxnMoaQRzPuEwFdCcBtUXwLLo15DHRNnkCNtJz5GHOdxzMjD2/NyBFaAsP aWfDugJpFsnfEgyMikWiYEGD57jeeOPJDw8SbxQmv53+0phkycRCG3199agyPVT2FKni +DDNksNY+0XWg+X6kcvBrzgGN/5tCKO+/oUU6rjYooBYgoWIiECuZGtA0Hd14vJm7+Ru 70Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780646457; x=1781251257; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=VUoRf71kuB7I15fGX7368Mh90WxDaXIoXoXn04xRBHo=; b=iWoBoaXrGc44Om7Vpn+5RUqTaBa8u72bANuJxOxhNsCFf2UguXyDRHM/4enMASkH2D U9EUHPSZHVeSPT07n7Lgt3srYAP2K4JhDkFTjIW/s3kIe77KzybfVz474Xgc6UndtKJ6 XxMtawBjQTYoQxq5YVTIzpjj74GBRRngo0xAwVKoxuopLEYlfaEp2vG9M6SBc/UWFG6v /qRyomBm4g0iGmWcYXSaczYAToPZmUcJy9Nxm8hEocMyw/+AEOGgy9YivcnEsDoHIWS/ hIssouyJY4dBetUjPWYFKSOnxHKEp/5on66W4/S6jaef/rDxTJ2QrErWa4+4J1XgBlqd 8ZLw== X-Forwarded-Encrypted: i=1; AFNElJ8Se2HQFeL834IdfWdAqmUXSCErh3XnNtW+T75OxA86ycF3y2K3HxbWzld3DpoxAh8H7bAtGwgSbPou@postgresql.org X-Gm-Message-State: AOJu0Yxhp+kaEt7EGYKdBg1CTB9hE9sRzNRlrbJlxUNOkLCw8HrizElE /S45zxN6gc+qyxtEZ9rBTUK0BF8KGOuRLzBEqt7H2+DydRX22ex+LRRHMh1Au+PP6tpT4yS2lNP wCIt/K/VF9+Yr43B9dzKUf4RtXr6WlFs= X-Gm-Gg: Acq92OHIgTe6TTSWfFPMmGgbGkV+nHh0BEkOPk6PqNwksjfef42XryqBBhuZTeGShW2 1nQcm+itotyuMIHfbbbqDoOU6IEGxBMyDBgYYQmhq0ChAUJaafyug5SvE9Oo7+A/a+jCExnSF0h JvRtb9v0xvmk9HhsiWhvYxIaLIc8w6yE8sikBZN6A26r9B/aEsfLuoZrUHn68TC4fM5ZGccdInV j0gYuuRBHTr/iO1zLg89+X6ndSyIkhyh+TdSk48Vf0OfxqD+L4z27/rBqjaJ6rfOoL2YPHOBHcD rDNS27GwKN44mQ/KGLsd/tJTw1DRuPieqpVAGF/DiRkTiRaz X-Received: by 2002:a05:7022:b9b:b0:137:f958:c072 with SMTP id a92af1059eb24-138066dfd6emr1098751c88.20.1780646457197; Fri, 05 Jun 2026 01:00:57 -0700 (PDT) MIME-Version: 1.0 References: <20260604002256.40f1fd544@smtp.qiye.163.com> In-Reply-To: From: Ashutosh Sharma Date: Fri, 5 Jun 2026 13:30:42 +0530 X-Gm-Features: AVHnY4ItQsvcAvqvvlb0JROVtx6KTxjT8iUj0NQ6SqgcptK626sXybI8tNO9El0 Message-ID: Subject: Re: Fw: Re: heap_force_common in contrib/pg_surgery/heap_surgery.c has an off by one stack buffer overflow To: Michael Paquier Cc: surya poondla , "violin0613@tju.edu.cn" , pgsql-bugs@postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Michael, Thanks for the patch. On Fri, Jun 5, 2026 at 12:27=E2=80=AFPM Michael Paquier wrote: > > On Fri, Jun 05, 2026 at 08:17:15AM +0900, Michael Paquier wrote: > > At the end, the first pattern is an outlier, we don't need to worry > > about performance in pg_surgery, and we're talking about three lines > > of code in pg_surgery to change (two for include_this_tid, one for the > > assertion). With all that in mind, I'd just do a -1 conversion and > > call it a day. :) > > Which implies something like the simpler patch attached. I have one small comment: "+ Assert((offno - 1) < MaxHeapTuplesPerPage);" I think this can be simplified to: Assert(offno <=3D MaxHeapTuplesPerPage); Since "offno" is already 1-based, there doesn't seem to be a need to subtract 1 from it and adjust the comparison accordingly. -- With Regards, Ashutosh Sharma.