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 1oF1NU-0002GI-A0 for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Jul 2022 22:44:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oF1NS-00006V-Ob for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Jul 2022 22:44:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oF1NS-00006L-FE for pgsql-hackers@lists.postgresql.org; Fri, 22 Jul 2022 22:44:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oF1NQ-0008JQ-4p for pgsql-hackers@postgresql.org; Fri, 22 Jul 2022 22:44:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 26MMi414763513; Fri, 22 Jul 2022 18:44:04 -0400 From: Tom Lane To: Nathan Bossart cc: Kyotaro Horiguchi , michael@paquier.xyz, gurjeet@singh.im, pgsql-hackers@postgresql.org Subject: Re: Unprivileged user can induce crash by using an SUSET param in PGOPTIONS In-reply-to: <20220722223359.GB3998906@nathanxps13> References: <20220722.151600.1094104349120879204.horikyota.ntt@gmail.com> <729330.1658516182@sss.pgh.pa.us> <20220722223359.GB3998906@nathanxps13> Comments: In-reply-to Nathan Bossart message dated "Fri, 22 Jul 2022 15:33:59 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <763511.1658529844.1@sss.pgh.pa.us> Date: Fri, 22 Jul 2022 18:44:04 -0400 Message-ID: <763512.1658529844@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart writes: > On Fri, Jul 22, 2022 at 02:56:22PM -0400, Tom Lane wrote: >> + if (!bootstrap && >> + !IsAutoVacuumWorkerProcess() && >> + !IsBackgroundWorker && >> + !am_walsender) >> + process_session_preload_libraries(); > I worry that this will be easily missed when adding new types of > non-interactive sessions, but I can't claim to have a better idea. Yeah, that bothered me too. A variant that I'd considered is to create a local variable "bool interactive" and set it properly in each of the arms of the if-chain dealing with authentication (starting about postinit.c:800). While that approach would cover most of the tests shown above, it would not have exposed the issue of needing to check am_walsender, so I'm not very convinced that it'd be any better. Another idea is to add a "bool interactive" parameter to InitPostgres, thereby shoving the issue out to the call sites. Still wouldn't expose the am_walsender angle, but conceivably it'd be more future-proof anyway? regards, tom lane