`MsgHdrMut::control_len` includes cmsg padding that `recvmsg` does not write
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 46/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- rust
- Bereich
- networking
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Rust
- Sterne
- 885
- Forks
- 328
- Ø Merge
- 6 T. 12 Std.
- Gemergte PRs (30 T.)
- 2
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus rust-lang/socket2
-
Commit lockfileOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
rust-lang/socket2#703 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
windows-sys 0.101.0Evtl. vergeben @xtqqczze hat das vor 3 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
SockAddr::path_len doesn't bound the length by sun_path: as_pathname panics since #691, as_abstract_namespace slices past itEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
`from_timeval` overflows on a non-normalised `tv_usec`Evtl. vergeben @pederbe hat das vor 18 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
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 fieldEvtl. vergeben @omrzk hat das vor 28 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
rust-lang/socket2#684 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in rust-lang/socket2
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
infra
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
available bug good first issue tooling
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Nixitov/Riptide-Native#817 ·
Maintainer antworten meist innerhalb von 1 Tag