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.94.2) (envelope-from ) id 1sRM62-00EePb-Pe for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2024 01:26:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sRM61-001MFb-Ey for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2024 01:26:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sRM60-001MFS-4r for pgsql-hackers@lists.postgresql.org; Wed, 10 Jul 2024 01:26:13 +0000 Received: from fout8-smtp.messagingengine.com ([103.168.172.151]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sRM5w-001IED-15 for pgsql-hackers@lists.postgresql.org; Wed, 10 Jul 2024 01:26:10 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfout.nyi.internal (Postfix) with ESMTP id E2BD11380AC4; Tue, 9 Jul 2024 21:26:06 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Tue, 09 Jul 2024 21:26:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1720574766; x=1720661166; bh=wSVVtaRQmW B9I9l6ClHwNSq0OL9KPOgBUeCsarpcnJM=; b=HrjXlVbi6cJFyVCIBZHcyqGmOY tr151vhDH2eB0Uq9dZnciyjw3cEYAa1IPHoJZX4/HUlIrCJMf7e2lwKxqCauaRZy Lok5mnFyvHrdWFXDs2VbmjMfcGtoqjM/2jHu57Gotexnk8foxw63DrdMy4Ai0ozE xejectB2pY8F/uuZchF1Soqg/2M8AJC4ktoqm+RG1hhcne5UGIT1UX3WbfK5hKNh h2yw8uFmD3Airhv2xr/sUO6b0bFsSv4Cd8jAMakKFvG+a/W2GLscTCTj2mmC0aAq YdqawrltlRzY6yk0l+c65wrg+q5NXNROdJt7Vu518LO//UCKdQG1u5etTjug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1720574766; x=1720661166; bh=wSVVtaRQmWB9I9l6ClHwNSq0OL9K POgBUeCsarpcnJM=; b=kB78B9G9fHm4Bcj95KQYgQicEDDUsvgmlfGusgcOIr3B I0F4ZgqKP1waWi3v/cjecavnlmpDh1J1PcEU47sX0iokTNrgNd4IFWphGH6b9Rrf TZ9DKsnWTSoR4IHuD9SmWvvaRr08ELYRWhl/lL1YRi/OunjecBZKMalotIhyM8NV H7tO2wmuJw+eA42QGlMHSm5ifwoocMr+MpgSniYuO0aTpU/pP6WAi1xtJdKRGz4S dTHwnC66mPtQS14zd/S9xpEZZd7t64RbkML6L+aopPW0uUfaD+EhZo7MghVAwbI/ i9tN0zbBmK5bbgUosVLxB12He9CP+T+FYY9MWgRPlQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrfedtgdegjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeg geffhfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 9 Jul 2024 21:26:04 -0400 (EDT) Date: Wed, 10 Jul 2024 10:25:49 +0900 From: Michael Paquier To: Joel Jacobson Cc: Tom Lane , Postgres hackers Subject: Re: pgsql: Add pg_get_acl() to get the ACL for a database object Message-ID: References: <3408967.1720107891@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2q4Jn0aFsftoO1Ci" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --2q4Jn0aFsftoO1Ci Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 08, 2024 at 11:55:28AM +0200, Joel Jacobson wrote: > Thanks, nice simplifications. > I agree the tests you removed are not that interesting. >=20 > Looks good to me. On second review, I have spotted a use-after-free for the case of an attribute ACL in both v1 and v2, as we would finish by releasing the syscache entry before returning the ACL datum. For builds with the flags -DRELCACHE_FORCE_RELEASE -DCATCACHE_FORCE_RELEASE, like the buildfarm member prion, this would cause lookup failures in the function when building the result because the datum is borked. At the end, I have settled down on using SearchSysCacheCopyAttNum(). It requires a heap_freetuple(), which we already don't care much about in the existing callers of get_catalog_object_by_oid() because these are short-lived, with bonus points because this routine uses SearchSysCacheAttNum() that has a check for attisdropped, making the=20 code of pg_get_acl() even simpler. The usual trick I use to check a fix with this configuration is to use two builds because initdb is insanely slow if caches are released: one with the flags and one without them. I have used the build without the flags to initialize a cluster with the objects and their ACLs. Then, the second build is used only to execute all the scenarios of pg_get_acl(), which are much cheaper to execute. -- Michael --2q4Jn0aFsftoO1Ci Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmaN4x0ACgkQnvQgOdby QH2w+Q//QFFoQpwDE+s/uUGu4RJa8Ysl4VjhfKCpf7Ffk+g5M6OCXnWetUHQbcyy 77PhPt9exvgPiP2ntRlvlpI2TgfGxiVv0jBAB/OJpf0mfghu09mSKvX7Z73QJ/Qy Nb2g93i/hL9nx2UjdwzlttGeV9QeGGVondANtQqSw7S8s1Ze6OIUoNP3TmeE1Lsj aDSDgKeOyIB7DWHoe54v2cP3qvIcO8tUeMOTJ4SKgVe2l4X9bE51aHA5jO4HdGDm 2RIC3gSnnHvFJJOpdjwikLwbdKX37zZewqAeYraDkeZw6x3eJEVsBvouOOvHiaH9 37gUZ9KZqzw9lKbramw6FHWF9xrWM9WC2Cm8gnvZZEwQjSRbRTnqLQSEZigXzE8u yxxH09Z7+ylg7sPPDM4IolH3dZb81tYtV51MdYAcKsC3WbWj+xybYFUUUmqLTg4l kG5xmRYlzr0lFP0O3z6PbQX9g+NMbGhieC7NbNOKxQzQ0snj7ao+TdPMm7BsloiY NzoRkYG6wBUtHTFDiaIDMdtZWINK8Ba/iHfaO5/d+rfSrDZXzEw41Se6q6yJi2Nj 7zq/2zhrrMJHk/YxqJVe4zdhoRA0kNpycUTJtKxA7OsYrP+hvw7wkX0iOBSn3W3r EtTX4ruTkNTLKiqh3cKe8bM2H2AD1k+KiBtspQ2QJUxCo/zc61g= =Fgwv -----END PGP SIGNATURE----- --2q4Jn0aFsftoO1Ci--