SIGBUS in quic_memfail_test on OpenBSD/sparc64 with clang

Aperta Adatta ai principianti
#33,731 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c

Direzione di ricerca

Inizia da test_quic_peer_token_fail() in test/quic_memfail_test.c, vicino alla riga 214, dove un letterale stringa viene convertito in struct in_addr. Il lato della libreria è BIO_ADDR_rawmake() in crypto/bio/bio_addr.c. Per riprodurre il problema serve una piattaforma con allineamento stretto, come OpenBSD/sparc64, eseguendo make test TESTS=test_quic_memfail. È completato quando il test non genera più SIGBUS, ad esempio copiando i byte con memcpy in una struct in_addr.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

issue: bug report

OpenSSL 4.1 added the test_quic_peer_token_fail() test via https://github.com/openssl/openssl/pull/31333.

It contains this line
https://github.com/openssl/openssl/blob/45c8f381b5513feaead63e294e901a5a58566bcb/test/quic_memfail_test.c#L214
which ends up doing the equivalent of *(struct in_addr *)"\x7f\x00\x00\x01" in BIO_ADDR_rawmake():
https://github.com/openssl/openssl/blob/0cb912ae302a85caaf7e3f698a336b1ac11ecab1/crypto/bio/bio_addr.c#L149
There is no guarantee that a string constant is properly aligned for this construct to be legal, and it happens to result in an unaligned access, hence SIGBUS on this architecture/OS/compiler when running

$ make test TESTS=test_quic_memfail

The "RAW ADDRESSES" section of the BIO_ADDR_rawmake() manual states

Both BIO_ADDR_rawmake() and BIO_ADDR_rawaddress() take a pointer to a network byte order address of a specific site. Internally, those are treated as a pointer to struct in_addr (for AF_INET), [...]

which suggests that the test source is at fault.

It is easy enough to fix or work around this by using memcpy() to place the string in a struct in_addr. The fix could happen in the test itself, or in the library source for the sake of robustness of BIO_ADDR_rawmake().

Lingua principale
C
Stelle
31.4k
Fork
11.6k
Merge medio
20m
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di openssl/openssl

Tutte le issue di openssl/openssl

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.