NetBSD aarch64: wrong `_ALIGNBYTES` breaks `CMSG_*` (CMSG_NXTHDR loops forever)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
- #5724 di @ci4ic4 — chiusa senza merge
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start in src/unix/bsd/netbsdlike/netbsd/aarch64.rs and compare _ALIGNBYTES with the AAPCS64 definition cited in the issue. The issue proposes using size_of::<u128>() - 1; done means the CMSG offsets and lengths match the reported NetBSD values and CMSG_NXTHDR advances correctly. Pull request #5724 is already open for this issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
src/unix/bsd/netbsdlike/netbsd/aarch64.rs defines
pub(crate) const _ALIGNBYTES: usize = size_of::<c_int>() - 1; // 3
but NetBSD/aarch64 uses the AAPCS64 branch of sys/arch/arm/include/cdefs.h:
#if defined(__ARM_PCS_AAPCS64)
#define __ALIGNBYTES (sizeof(__int128_t) - 1) /* 15 */
#elif defined(__ARM_EABI__)
#define __ALIGNBYTES (sizeof(long long) - 1)
#else
#define __ALIGNBYTES (sizeof(int) - 1)
#endif
_ALIGNBYTES is only used by CMSG_DATA, CMSG_LEN, CMSG_NXTHDR and CMSG_SPACE, and all four come out wrong:
| NetBSD 11.99.10 evbarm (aarch64) | C (<sys/socket.h>) |
libc 0.2.191 |
|---|---|---|
sizeof(struct cmsghdr) |
12 | 12 |
CMSG_DATA offset |
16 | 12 |
CMSG_LEN(4) |
20 | 16 |
CMSG_SPACE(4) |
32 | 16 |
C values came from a small program built with the system cc. The libc values follow from _ALIGN(12) == 12 with _ALIGNBYTES == 3.
Impact
Code that parses control messages from the kernel reads them at the wrong offsets. CMSG_NXTHDR steps into padding, reads cmsg_len == 0, and returns the same header again, so a loop like while !cmsg.is_null() never ends. I hit this with sendme / iroh (noq-udp, which is a fork of quinn-udp): the first received UDP datagram puts a tokio worker into a 100% CPU loop with no syscalls. quinn-udp should be affected the same way. Building control messages with CMSG_SPACE/CMSG_LEN is also wrong, so the kernel will reject or misread them.
x86_64 is unaffected, because both C and the crate use sizeof(long) - 1. I haven't checked NetBSD arm (32-bit) or riscv64 on real hardware. Their crate values (c_longlong, __BIGGEST_ALIGNMENT__) look consistent with the C headers.
Fix
pub(crate) const _ALIGNBYTES: usize = size_of::<u128>() - 1;
With this change (as a vendored patch in pkgsrc), sendme works on NetBSD/aarch64 (transfers in both directions with NetBSD/amd64, hashes verified).
- Lingua principale
- Rust
- Stelle
- 2.7k
- Fork
- 1.4k
- Merge medio
- 3g 2h
- PR unite (30g)
- 45
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rust-lang/libc
-
NetBSD: `kevent()` updatedApertaC-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
rust-lang/libc#5801 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
C-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
SYS_kexec_file_load missing for aarch64-unknown-linux-muslForse già presa @AdmerPRO l’ha presa 5 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
rust-lang/libc#5722 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Expose `open_how` on AndroidForse già presa @rizzabhdwaj l’ha presa 35 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
rust-lang/libc#5673 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di rust-lang/libc
Issue simili
-
Test connection's password prompt says the password is never saved, also for a keychain profileApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
area: settings bug Haiku review: no-score ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MMFoundation/WallpaperMachine#346 ·
I maintainer di solito rispondono entro 1 giorno
-
Make the HTTP server's keep-alive and headers timeouts configurableForse già presa @mattgodbolt l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
compiler-explorer/compiler-explorer#9902 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
jonathanong/no-mistakes#5490 ·
-
follow-up
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno