Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3gKg-0000pU-N4 for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jul 2021 14:57:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m3gKf-0006gQ-LQ for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jul 2021 14:57:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3gKf-0006gH-Dw for pgsql-hackers@lists.postgresql.org; Wed, 14 Jul 2021 14:57:53 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m3gKd-0002lN-53 for pgsql-hackers@lists.postgresql.org; Wed, 14 Jul 2021 14:57:53 +0000 Received: by mail-pf1-x435.google.com with SMTP id 21so2279857pfp.3 for ; Wed, 14 Jul 2021 07:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=oeMD0adPpgiR7rxSkr2KVbGXaAyqTY5/nS3nqtlxb/s=; b=ltojwAh372/ujpTCgAhySBv6b2/wdqF8Mh/XRdeGnt+fUqlCtURjHYPef/vkRj1VSU /aOtLOws4O/xXSu0tIRh8te4wRXpbys2PBSyO64keFbz2jrVWHCyvdHDrxiz3quNd8N+ WmyEOHJ+u+J797+pU/3ICFJd9sYyJO5YeW/sAOdbL+zv2PmYOpaUJGPkX8nyAenU3YE6 VZa0aqXlfvfRzcP0jtJWsblJWiJmM9bltHVU7W/31QHOFTX1eNMHdd+piq9qw9pryTlF s4EOoaa6OZzRsD8USpkJ8MeOZttgBg/aqvJy3/DmKStNmaiZagB1R39Fkwz3nqVjISC3 eQMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=oeMD0adPpgiR7rxSkr2KVbGXaAyqTY5/nS3nqtlxb/s=; b=ONBGqpXTOyr+xYRTcaC1sYVECDOvm7NyyWe0HUakpSWLTNIM8OZBA9jjXW+XpTb4OG QfCTqTENXW6u1Q2lHROLo/tFfwb48yE/p4Lmrd/UrSGk4krfR4iaQLwMMtZNvKLeK3eT hbWOcMpUDMi6O/0P1MMQIIIEk1BgTFTcmh+WFFYg11uTirSO7x8fyjTIe09K5ERCqbcF HVzSFj253CQJLMJ2Z6VFGKrHbWBxwUCsvjZ/UneE083iF9j2+RbMLKkL2POpUQIpeXBr Cjf92jDdyIXw67bjmY1ek2yuXhOwngT4miuL5O0UhcedOC3s7XOw/8c1VKl64CwAaQ1h fCDw== X-Gm-Message-State: AOAM533LUbipEAGkw0EIsL2Ov2WlakJs75FMM/qmGY0nDh2h7WUeJ0ME y5gIejbLKyZvutG+hgaO1FQYqSEhlMaBe7sJcEQwjv/UXS8MB+Q3uUk6mNxdk8jZR1mzrG6Wcfa e8WEzriGR3nMKZIGIjfvjPn2wzqhJQn7bDPgVzpI0ZLGy3BCvlM6VXUr3yElhS8jrTiU2wD4ueO CJLPY6u5Df7lOcCiP2bxIwonOdt+SBeuZgppIJ4Jkt5e5whP7mBWnt X-Google-Smtp-Source: ABdhPJwVRj/ShAixUDPBgXx93iotekxHwhKSiDGQudnv0MjI8t6x4Vennsb0KqRTEmQ+XpZbTOQ8jA== X-Received: by 2002:a63:6642:: with SMTP id a63mr9965269pgc.241.1626274668927; Wed, 14 Jul 2021 07:57:48 -0700 (PDT) Received: from laptop280-ma-us.hitronhub.home (24-113-193-150.wavecable.com. [24.113.193.150]) by smtp.gmail.com with ESMTPSA id p38sm2855541pfh.151.2021.07.14.07.57.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jul 2021 07:57:48 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: Extending amcheck to check toast size and compression From: Mark Dilger In-Reply-To: <8729a485-e138-2e18-0d66-74f15ac0c3cc@iki.fi> Date: Wed, 14 Jul 2021 07:57:47 -0700 Cc: Aleksander Alekseev , pgsql-hackers@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <29751EFD-91D8-4F2F-8416-030AD067F260@enterprisedb.com> References: <484213DD-9F6E-440F-885F-0B31C600430F@enterprisedb.com> <162083278007.16755.9306912342451528285.pgcf@coridan.postgresql.org> <8729a485-e138-2e18-0d66-74f15ac0c3cc@iki.fi> To: Heikki Linnakangas X-Mailer: Apple Mail (2.3608.120.23.2.7) X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Jul 14, 2021, at 3:33 AM, Heikki Linnakangas = wrote: >=20 >> +/* The largest valid toast va_rawsize */ >> +#define VARLENA_SIZE_LIMIT 0x3FFFFFFF >> + >=20 > Hmm, a toasted datum cannot be larger than MaxAllocSize, because it's = reconstituted in a palloc'd datum, right? No datum size exceeds MaxAllocSize, and no datum expands when compressed = (because for those that do expand under any particular compression = algorithm, we opt to instead store the datum uncompressed), so no valid = toast pointer should contain a va_rawsize field greater than = MaxAllocSize. Any toast pointers that have larger va_rawsize fields are = therefore corrupt. VARLENA_SIZE_LIMIT is defined here equal to MaxAllocSize: src/include/utils/memutils.h:#define MaxAllocSize ((Size) = 0x3fffffff) /* 1 gigabyte - 1 */ Earlier versions of the patch used MaxAllocSize rather than defining = VARLENA_SIZE_LIMIT, but review comments suggested that was less clear. =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company