Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fhoiW-0000dc-73 for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jul 2018 04:14:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fhoiR-0000dw-Ph for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jul 2018 04:14:27 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fhoiQ-0000dp-CG for pgsql-hackers@lists.postgresql.org; Tue, 24 Jul 2018 04:14:27 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fhoiJ-0000AO-0Y for pgsql-hackers@postgresql.org; Tue, 24 Jul 2018 04:14:25 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id D44847A7; Tue, 24 Jul 2018 00:14:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 24 Jul 2018 00:14:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=b7rna0Fns3er+GJa21eKmsz2OZb5xgha2Dw6HrMOx74=; b=SpIYvPVt fIzo2DqdfmGB+uwsbMq7IUFbyeEBUiPVNnq94sci6jD0V7scfaSl64wNyG7Nu80E rqbf3W0AfVqAMctc9jrG2F9PGJLTnZErbIlQILVnPhpYJPfqmyl5S5cGbRQCL+22 OnmnmTmxPOZyz9MgpsYFrjvlCy6WpB6djo66EiMxNldOb4oDQnbW4MKix/M0Uf9K 4J357PUGTdP94KcOTkJ0Kqr3IbrOGqCJXOfyO7Ri1pbTUKfVqvLMqdUOefkG/sb0 OZALPb8mHaWtr8/h48S4/Xo8kuxoOIK77QIvRlWX8DPl8y56cjb7yqP3bUApsJDI 300qFkv0453tkw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=b7rna0Fns3er+GJa21eKmsz2OZb5x gha2Dw6HrMOx74=; b=dpejH5CfnDgjt2U8XT3lCi1IeHyyYDg/NF0yh5kdBL+UT gcw0ZM9Ap/7KqzxkP/sjQtJ0YYVC1AYdK2QlfIg1GQU2pdU17l0gyhBPjECiLwIT yl1QOCy4UDLFIJgz37/77VpVU5lEiiMmUCqr7vGRW3WHhRDDSV/EJLvxge60luoY u2e1utBwQgqyhrENM33hUAPO7zSuNpe4lidGb89CMHGu2DnA3PWpsLLj7YsX+sj0 c7abh+AukAPqBYRR4V96391/IRzv2VlkTGU++6Zs7YtfefedEq6FJAX0WxYTnGhU 94y6kdlL2Knd9G3QIA4tpZ92Y55Ww3L5/q76qwCAg== X-ME-Proxy: X-ME-Sender: Received: from paquier.xyz (mp76f1f82d.ap.nuro.jp [118.241.248.45]) by mail.messagingengine.com (Postfix) with ESMTPA id 48F161026B; Tue, 24 Jul 2018 00:14:14 -0400 (EDT) Date: Tue, 24 Jul 2018 13:14:03 +0900 From: Michael Paquier To: Robert Haas Cc: Jeremy Schneider , PostgreSQL-development , "Albin, Lloyd P" Subject: Re: BUG #15182: Canceling authentication due to timeout aka Denial of Service Attack Message-ID: <20180724041403.GF4035@paquier.xyz> References: <152512087100.19803.12733865831237526317@wrigleys.postgresql.org> <9145334b-9583-124c-012e-7d58039ad417@amazon.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="IvGM3kKqwtniy32b" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --IvGM3kKqwtniy32b Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jul 23, 2018 at 11:29:33AM -0400, Robert Haas wrote: > ExecuteTruncate needs to be refactored to use RangeVarGetRelidExtended > with a non-NULL callback rather than heap_openrv, and > expand_vacuum_rel needs to use RangeVarGetRelidExtended with a > callback instead of RangeVarGetRelid. See > cbe24a6dd8fb224b9585f25b882d5ffdb55a0ba5 as an example of what to do. > I fixed a large number of cases of this problem back around that time, > but then ran out of steam and had to move onto other things before I > got them all. Patches welcome. Thanks for pointing those out, I looked at both code paths recently for some other work... The amount of work does not consist just in using for example RangeVarCallbackOwnsRelation for VACUUM and TRUNCATE. There are a couple of reasons behind that: - While it would make sense, at least to me, to make VACUUM fall into if allow_system_table_mods is allowed, that's not the case of ANALYZE as I think that we should be able to call ANALYZE on a system catalog as well. So we would basically a new flavor of RangeVarCallbackOwnsRelation for VACUUM which makes this difference between vacuum and analyze with an argument in the callback, the options of VacuumStmt would be nice. This would not be used by autovacuum anyway, but adding an assertion and mentioning that in the comments would not hurt. There is an argument for just restricting VACUUM FULL as well and not plain VACUUM, as that's the one hurting here. - TRUNCATE is closer to a solution, as it has its own flavor of relation checks with truncate_check_rel. So the callback would replace truncate_check_rel but CheckTableNotInUse should be moved out of it. TRUNCATE already uses allow_system_table_mods for its checks. Thoughts? -- Michael --IvGM3kKqwtniy32b Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAltWp4sACgkQnvQgOdby QH3rJhAAghUxGLx1XhnBRmrfg5zke8bK3n1H1wB/KLrgzjC8Y+phLcxDjQoCrZiy fkmSUU83S6cJ25bIItv70bLk8fAVBr+BzeVUw7Mkl7ND1lAW0x5e/XrArFVnoYb5 Q6FSaRZLSNXlembOslsFau3DGd4Ojo0GL+iHB+VhBXOJDs3+mnxj2iv8YVRRDvzN t2j8I2OHdvewoHAo7D3LI5JWmhXuydm8M43PVbWNalWBMprbUidy0MzthToblILn fftn0a/eRuxWV0muxCSU7ZiukwXMTusRi6tYG3BN2RADxNhzIjuge8md0GJb39c+ R/b7kC970yMCi/ywbNHmzBs2w5R9SxMv4FDSHZrybbyQjF73vxZZKKG8GiuJgBFR 9M0y536PQpfkc46O0h4OsE+8gbKdZMJSNXxYNW7YsUrgIz1tGKSpSUDFbpQ+dQae Uy0oNftsPgBWSYJO5fMZvpcnH9OxniSWc+rIqeY2pFt6tl+QE6A4zv3Y2tSoAJme xPbp/IGucUbdkJSq5Zn3DwKPteA3YOkOcDoAswgUvlE7ZiLxZK+eARe6pQPEh0B3 VwKVE70Y8HZPVxbC61LIkZfduPYdG2VwcQYOHT+13cO8IZ2PS8HwC6WuCgWdzZWy t2WaEMlGDahShgfc5jyoz5yUI3C4Wf5XMhHBT3IiEra2WARMDC4= =AlUz -----END PGP SIGNATURE----- --IvGM3kKqwtniy32b--