agora inbox for pgsql-hackers@postgresql.org  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Mats Kindahl <mats@timescale.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: glibc qsort() vulnerability
Date: Wed, 7 Feb 2024 19:52:11 -0600
Message-ID: <20240208015211.GA445153@nathanxps13> (raw)
In-Reply-To: <20240208004207.aoyrtv577nmhrivy@awork3.anarazel.de>
References: <CA+14426g2Wa9QuUpmakwPxXFWG_1FaY0AsApkvcTBy-YfS6uaw@mail.gmail.com>
	<508821.1707232276@sss.pgh.pa.us>
	<20240206205305.GB3891538@nathanxps13>
	<642084.1707252958@sss.pgh.pa.us>
	<CA+14425TqyUZ3-O7zYsW6u85yY5diCz-p_TPQ2bZovn-N-fQ9A@mail.gmail.com>
	<cc9b0272-849a-4a88-8200-59786d18b7a1@iki.fi>
	<20240207214857.rjqkutiaapka2xyp@awork3.anarazel.de>
	<20240207222124.GA382832@nathanxps13>
	<20240208004207.aoyrtv577nmhrivy@awork3.anarazel.de>

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 and a ~3.4% improvement with this:

    int
    compASC(const void *a, const void *b)
    {
        int         result;

        if (unlikely(pg_sub_s32_overflow(*(const int32 *) a,
                                         *(const int32 *) b,
                                         &result)))
        {
            if (*(const int32 *) a > *(const int32 *) b)
                return 1;
            if (*(const int32 *) a < *(const int32 *) b)
                return -1;
            return 0;
        }

        return result;
    }

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com





view thread (64+ messages)  latest in thread

Message-ID: <20240208015211.GA445153@nathanxps13>
Permalink:  ../20240208015211.GA445153@nathanxps13/
Also on:    postgresql.org/message-id/20240208015211.GA445153@nathanxps13

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: nathandbossart@gmail.com, andres@anarazel.de, hlinnaka@iki.fi, mats@timescale.com, tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org
  Subject: Re: glibc qsort() vulnerability
  In-Reply-To: <20240208015211.GA445153@nathanxps13>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox