Re: glibc qsort() vulnerability

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Хамидуллин Рустам <r(dot)khamidullin(at)postgrespro(dot)ru>
Cc: Mats Kindahl <mats(at)timescale(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: glibc qsort() vulnerability
Date: 2026-07-24 20:01:13
Message-ID: amPEiUFpt1RNhYBk@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 24, 2026 at 06:12:03PM +0300, Хамидуллин Рустам wrote:
>  static int 
>  db_comparator(const void *a, const void *b) 
>  { 
> -    if (((const avl_dbase *) a)->adl_score == ((const avl_dbase *) b)->adl_score) 
> -        return 0; 
> -    else 
> -        return (((const avl_dbase *) a)->adl_score < ((const avl_dbase *) b)->adl_score) ? 1 : -1; 
> +    return pg_cmp_s32(((const avl_dbase *) a)->adl_score, 
> +                      ((const avl_dbase *) b)->adl_score); 
>  } 
>
> It breaks the database vacuuming order. The order should clearly be different here. 
> This bug was introduced in PostgreSQL 17. I have attached а fix. 

Oops, I think you're right. Thanks for reporting. I'll plan on committing
this sometime next week.

--
nathan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Brazeal 2026-07-24 20:04:34 bug: query returns different result with and without memoization.
Previous Message Yugo Nagata 2026-07-24 17:51:59 Re: Track skipped tables during autovacuum and autoanalyze