`MsgHdrMut::control_len` includes cmsg padding that `recvmsg` does not write
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 46/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- rust
- Domaine
- networking
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Rust
- Étoiles
- 885
- Forks
- 328
- Merge moyen
- 6 j 12 h
- PR mergées (30 j)
- 2
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de rust-lang/socket2
-
Commit lockfileOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
rust-lang/socket2#703 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
windows-sys 0.101.0Peut-être pris @xtqqczze l’a pris il y a 3 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
Les mainteneurs répondent en général sous 1 jour
-
SockAddr::path_len doesn't bound the length by sun_path: as_pathname panics since #691, as_abstract_namespace slices past itPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
`from_timeval` overflows on a non-normalised `tv_usec`Peut-être pris @pederbe l’a pris il y a 18 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
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 fieldPeut-être pris @omrzk l’a pris il y a 28 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
rust-lang/socket2#684 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de rust-lang/socket2
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
infra
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
available bug good first issue tooling
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Nixitov/Riptide-Native#817 ·
Les mainteneurs répondent en général sous 1 jour