`MsgHdrMut::control_len` includes cmsg padding that `recvmsg` does not write
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 46/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- networking
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Rust
- Star
- 885
- Fork
- 328
- Merge trung bình
- 6 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rust-lang/socket2
-
Commit lockfileĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
rust-lang/socket2#703 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
windows-sys 0.101.0Có thể đã có người làm @xtqqczze đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
SockAddr::path_len doesn't bound the length by sun_path: as_pathname panics since #691, as_abstract_namespace slices past itCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`from_timeval` overflows on a non-normalised `tv_usec`Có thể đã có người làm @pederbe đã nhận 18 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
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 fieldCó thể đã có người làm @omrzk đã nhận 28 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
rust-lang/socket2#684 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rust-lang/socket2
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
infra
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
available bug good first issue tooling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Nixitov/Riptide-Native#817 ·
Maintainer thường phản hồi trong vòng 1 ngày