`MsgHdrMut::control_len` includes cmsg padding that `recvmsg` does not write
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 46/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- networking
Direzione di ricerca
Start from the definition of MsgHdrMut::control_len and MsgHdrMut::with_control; compare the documented guarantee against how recvmsg advances msg_controllen with CMSG_SPACE while writing only CMSG_LEN bytes. Reproduce with the payload's Socket::pair/MaybeUninit snippet, then choose the documentation-only or zeroing approach and add a regression test. Done means the docs say to walk control messages with CMSG_FIRSTHDR/CMSG_NXTHDR, or the buffer is initialized so control[..control_len()] is safe, with the reproduction covered.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The documentation of MsgHdrMut::control_len says it "can be used to determine how much, if any, of the control buffer was filled by recvmsg". Since the control buffer is &mut [MaybeUninit<u8>], callers will reasonably treat control[..control_len()] as initialised. On Linux, though, the kernel advances msg_controllen by CMSG_SPACE(len) for each control message but writes only CMSG_LEN(len) bytes, so the alignment padding after each payload is counted and never written. With an uninitialised buffer, reading control[..control_len()] as &[u8] is then undefined behaviour in the caller.
Receiving one SCM_RIGHTS message with one fd over a Socket::pair(Domain::UNIX, Type::DGRAM, None), into control buffers pre-filled with 0xAA and then 0x55:
let mut control = [MaybeUninit::new(fill); 64];
let mut hdr = MsgHdrMut::new().with_buffers(&mut bufs).with_control(&mut control);
b.recvmsg(&mut hdr, 0).unwrap();
let len = hdr.control_len(); // 24
// bytes 20..24 still hold `fill` after both calls
control_len() = 24
bytes [20, 21, 22, 23] of control[..24] were not written by recvmsg: 0xaa / 0x55 left from the pre-fill
Run with socket2 0.6.5 and current master (b6c3b8e), Rust 1.100.0, glibc 2.39 and Linux 6.14 on x86_64.
A fix could be to document that only the cmsg_len bytes of each message are written and that the buffer should be walked with CMSG_FIRSTHDR/CMSG_NXTHDR, or to zero the buffer in with_control so that the current wording holds.
Found by Crustify, an experimental UB/soundness auditing agent developed at UC Berkeley and running on Claude Opus 5.5, then manually reviewed and independently reproduced.
- Lingua principale
- Rust
- Stelle
- 885
- Fork
- 328
- Merge medio
- 6g 12h
- PR unite (30g)
- 2
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun 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/socket2
-
Commit lockfileAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
rust-lang/socket2#703 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
windows-sys 0.101.0Forse già presa @xtqqczze l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
SockAddr::path_len doesn't bound the length by sun_path: as_pathname panics since #691, as_abstract_namespace slices past itForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
`from_timeval` overflows on a non-normalised `tv_usec`Forse già presa @pederbe l’ha presa 18 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Build fails on 32-bit glibc (i686, armv7) with libc's `--cfg=libc_unstable_time64`: `tv_usec` is cast to `suseconds_t` (i32) for an i64 fieldForse già presa @omrzk l’ha presa 28 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
rust-lang/socket2#684 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di rust-lang/socket2
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
infra
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
available bug good first issue tooling
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Nixitov/Riptide-Native#817 ·
I maintainer di solito rispondono entro 1 giorno