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 1rXtoR-00DCod-2u for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Feb 2024 02:06:52 +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 1rXtoN-00EIeV-Lj for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Feb 2024 02:06:47 +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 1rXtoL-00EIeH-Qo for pgsql-hackers@lists.postgresql.org; Thu, 08 Feb 2024 02:06:47 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rXtoI-005dUF-ME for pgsql-hackers@lists.postgresql.org; Thu, 08 Feb 2024 02:06:44 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 342BF5C010A; Wed, 7 Feb 2024 21:06:40 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 07 Feb 2024 21:06:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; 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=fm3; t=1707358000; x=1707444400; bh=KYuaR2Pxcq +QqDEi5tdmqZ6C0p5xl42aVtJ1rCUYD0c=; b=qJa4BHwrK7oAniDxSKeiPd6X9s f5iipxENCcNm08J0rlYzO0XGrnhmT1pClUxCkzxKH+n7/6SaU5sM/I577IYLzBeQ 990+g227OU3eZ7zOTrdm274qp6wZeIyRpa2wm3r3XmtpPFH1WHyPRKpgcpSfqC+q 9BxnCBGbRfr7dGrRS06ltKXveUm6yW1XnS4M8CdxgGN2ZkTK0PAuKdXKxbiSWUXv CLsTQlh7LChnWmcg5Jl12BZtKMKb9srhjI99BifpgZqA1n7xPqjDygj2NpLhojAo wMviiiXteoPpU3J9VNydqQkzePdx73uba2UV0EPaA4azI3vo8QqOqG49G3zA== 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= fm3; t=1707358000; x=1707444400; bh=KYuaR2Pxcq+QqDEi5tdmqZ6C0p5x l42aVtJ1rCUYD0c=; b=Fwl5dAgnGdDrhDYTFlWgaYkTYZ4cJmEGVAzSBaYboPge u5C7Dl+9zNCZfeGYBCDRo7eWLfSZaDS+gRn3Gvy7PTsmFt6BTnKBuDCIX28hZB0d Cys+sKpzdWCI2mYkap5hqgnQ+vcky5K1hp/ph/tREQoCqaPL3pWO970TkqTEXYE9 tDSEt3zDAS3ETbxi1dsSED2nsj5HlA0/820V20bO6aQD1Nph8LhjrKQbXohnNHHO Hl+mUpPldvMVj7Yhi/Io357N2Ys4QTaIbeLxh1x+JPmjZvg3fpKjccBDGxc4H8sl bmlAHCvHiZ1sdnyv+aBKY4pjtdSFfN3fOpz1rYl9oA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrtdefgdegfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpedvffefvefhteevffegieetfefhtddvffejvefhueetgeeludehteevudei tedtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Feb 2024 21:06:39 -0500 (EST) Date: Wed, 7 Feb 2024 18:06:37 -0800 From: Andres Freund To: Nathan Bossart Cc: Heikki Linnakangas , Mats Kindahl , Tom Lane , pgsql-hackers@lists.postgresql.org Subject: Re: glibc qsort() vulnerability Message-ID: <20240208020637.3irwi5vph4fbxw2f@awork3.anarazel.de> References: <508821.1707232276@sss.pgh.pa.us> <20240206205305.GB3891538@nathanxps13> <642084.1707252958@sss.pgh.pa.us> <20240207214857.rjqkutiaapka2xyp@awork3.anarazel.de> <20240207222124.GA382832@nathanxps13> <20240208004207.aoyrtv577nmhrivy@awork3.anarazel.de> <20240208015211.GA445153@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240208015211.GA445153@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2024-02-07 19:52:11 -0600, Nathan Bossart wrote: > On Wed, Feb 07, 2024 at 04:42:07PM -0800, Andres Freund wrote: > > On 2024-02-07 16:21:24 -0600, Nathan Bossart wrote: > >> The assembly for that looks encouraging, but I still need to actually test > >> it... > > > > Possible. For 16bit upcasting to 32bit is clearly the best way. For 32 bit > > that doesn't work, given the 32bit return, so we need something more. > > For the same compASC() test, I see an ~8.4% improvement with your int64 > code Just to be clear, that code unfortuntely isn't correct, the return value is a 32 bit integer, so the 64bit difference doesn't help. In contrast to the 16bit case. > and a ~3.4% improvement with this: I guess that's still something. Another branchless variant is (a > b) - (a < b). It seems to get a similar improvement as the overflow-checking version. Greetings, Andres Freund