pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bastien Roucariès <rouca@debian.org>
To: pgsql-bugs@lists.postgresql.org, Heikki Linnakangas <hlinnaka@iki.fi>
To: pgsql-bugs@lists.postgresql.org, Heikki Linnakangas <hlinnaka@iki.fi>
Subject: Re: Detection of hadware feature => please do not use signal
Date: Thu, 31 Oct 2024 17:42:09 +0000
Message-ID: <193820057.q8YS0ZdlI3@portable-bastien> (raw)
In-Reply-To: <af84e934-4e9c-4380-95ee-8921dab1254b@iki.fi>
References: <4496616.iHFcN1HehY@portable-bastien>
	<af84e934-4e9c-4380-95ee-8921dab1254b@iki.fi>

Le jeudi 31 octobre 2024, 17:29:45 UTC Heikki Linnakangas a écrit :
> On 31/10/2024 17:41, Bastien Roucariès wrote:
> > Hi,
> > 
> > On debian side we will like to avoid use of sigill to detect feature.
> > 
> > https://sources.debian.org/src/postgresql-17/17.0-1/src/port/pg_crc32c_armv8_choose.c/#L55
> > 
> > is really bad.
> 
> Why is it bad?

for a binary it is maybe safe for a library it is unsafe in Multi thread context to capture signal...
And we are burned by a recent CVE in ssh due to signal handling.
> 
> > Could you use the canonical way under linux
> > 
> > #include <sys/auxv.h>
> > #include <asm/hwcap.h>
> > 
> >   #if defined(__aarch64__)
> >     return !(getauxval(AT_HWCAP) &  HWCAP_CRC32);
> >   #else
> >     return !(getauxval(AT_HWCAP2) & HWCAP2_CRC32);
> >   #endif
> 
> We used to do that, but it was changed in commit 1c72ec6f. Looking at 
> the discussion that led to it, it's not clear to me why we switched [1]. 
> Portablity to non-glibc systems maybe?

Yes I suppose but a
#ifdef __GLIBC__

#else

#endif

Will be safe
> 
> If there's a handy, portable way to check CPU capabilities, I agree it 
> seem less hacky than catching SIGILL...

unfortunatly no
> 
> [1] 
> https://www.postgresql.org/message-id/CAEepm%3D02Run-Pk3xyt%2BRV3p1N%2B7cKZxN95_MamaJw8Cnw%2BDwjQ%40...
> 
> 

Attachments:

  [application/pgp-signature] signature.asc (832B, ../193820057.q8YS0ZdlI3@portable-bastien/2-signature.asc)
  download

view thread (37+ messages)  latest in thread

Message-ID: <193820057.q8YS0ZdlI3@portable-bastien>
Permalink:  ../193820057.q8YS0ZdlI3@portable-bastien/
Also on:    postgresql.org/message-id/193820057.q8YS0ZdlI3@portable-bastien

 · 

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-bugs@postgresql.org
  Cc: rouca@debian.org, hlinnaka@iki.fi
  Subject: Re: Detection of hadware feature => please do not use signal
  In-Reply-To: <193820057.q8YS0ZdlI3@portable-bastien>

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

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