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 1oFoxg-0006o2-Vm for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Jul 2022 03:40:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oFoxe-0004tC-Q6 for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Jul 2022 03:40:50 +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 1oFoxe-0004t2-ET for pgsql-hackers@lists.postgresql.org; Mon, 25 Jul 2022 03:40:50 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oFoxZ-00063p-LP for pgsql-hackers@postgresql.org; Mon, 25 Jul 2022 03:40:50 +0000 Received: by mail-pg1-x52b.google.com with SMTP id f65so9205169pgc.12 for ; Sun, 24 Jul 2022 20:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=wcJSLE8l8qGD1lFY1iGRjE7AkaqXCGrTrt9tMhQv+ec=; b=FbSPvn4v1wYoSTd7SyhOoatnokj2rqmEJypJ3YScHxS3wzGVUKoFwK253nkQeAH3Wy jXH4StWamNm1YyKzM4UP+wUwa5btlO45FMNGIPX2A1Zpxyu1WFX+5Nw/QKZpMnPCmX7E 6CJKWCu2te0ALZhlrBqJPzlqglc7NTIxoL1aVVLbQBVweeOIPn3rsZK4qkmELZmJ3vk3 cyeS5PuIkFQg9o3hxerfR6jnegDIBL80CesAQKo0SUNphKB6iIis4Qb0DvhvyrFMkjtW jl5VKGd8aPZQe96Be660PrPh3mQRbRtVzrD1gxVgQ6CM+6hoEfeyA1Sjmo6+09nT5nGe kzXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=wcJSLE8l8qGD1lFY1iGRjE7AkaqXCGrTrt9tMhQv+ec=; b=oCAU4k2h7mOgngpNv4HN/RgNM1NQ8fUsFzHYQewTnNgZ3xwvyI2CIoFkHSIrRpUvi5 frlh1wnImQ8b7mtkFNJDQQob3qJmCBNSX4rLimIzHkQHZIQml34r+DtevetKi/pFbG4b JizgXb9swZfStO3LI4LF/KeL3rEdTNBouOl7Qhl3Dve/TBfdC1e4fil1xo4mqj/UWAzD iLwpUYZ2qik1xye5/OxMvOxNAZzACPhn6L71lTrOq/ZJvrde7xJx+iwa8q2inOvMTbO9 ZN7xakj0z40+z9G41N7cMYN2autizxTFVbKhU5bQSmnNfJKNm2DEEtJd0eXp2QELYVUr N3dA== X-Gm-Message-State: AJIora+fiFZZQ8p7y8k46eZoXq13TffF6kP4sGW7RdmRGDtLrSmiKJe8 Wf1Jr9Q5vUYDWdidHZEYuc4= X-Google-Smtp-Source: AGRyM1vH48RQVegn+4r/frbdAgbGSqDiPAtD4VmTODSYLfBhE5JowXwKgCbm3zaP7nw1yDly+3IbPw== X-Received: by 2002:a63:d445:0:b0:41a:fbe1:952c with SMTP id i5-20020a63d445000000b0041afbe1952cmr2468785pgj.310.1658720443337; Sun, 24 Jul 2022 20:40:43 -0700 (PDT) Received: from nathanxps13 ([50.54.155.70]) by smtp.gmail.com with ESMTPSA id a189-20020a624dc6000000b0052b2e8d0894sm8518564pfb.16.2022.07.24.20.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jul 2022 20:40:42 -0700 (PDT) Date: Sun, 24 Jul 2022 20:40:40 -0700 From: Nathan Bossart To: Tom Lane 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 Message-ID: <20220725034040.GA4085281@nathanxps13> References: <20220722.151600.1094104349120879204.horikyota.ntt@gmail.com> <729330.1658516182@sss.pgh.pa.us> <20220722223359.GB3998906@nathanxps13> <763512.1658529844@sss.pgh.pa.us> <20220722225615.GC3998906@nathanxps13> <954936.1658597004@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <954936.1658597004@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, Jul 23, 2022 at 01:23:24PM -0400, Tom Lane wrote: > - /* > - * process any libraries that should be preloaded at backend start (this > - * likewise can't be done until GUC settings are complete) > - */ > - process_session_preload_libraries(); This patch essentially moveѕ the call to process_session_preload_libraries() to earlier in PostgresMain(). The discussion upthread seems to indicate that this is okay. I did notice that the log_disconnections handler won't be set up yet, so failures due to session_preload_libraries won't be logged the same way as before. Also, the call to pgstat_report_connect() won't happen. Neither of these strikes me as particularly bad, but it seemed worth noting. > + * load_session_libraries: TRUE to honor session_preload_libraries nitpick: Should we call out local_preload_libraries here, too? > + if (load_session_libraries) > + process_session_preload_libraries(); I noticed that a couple of places check whether whereToSendOutput is set to DestRemote to determine if this is an interactive session. Maybe something like if (whereToSendOutput == DestRemote && !am_walsender) would be a reasonably future-proof way to avoid the need for a new InitPostgres() argument. Otherwise, the patch looks good to me. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com