Skip to content

std: fix Xous UDP send_to length mismatch and truncation#158928

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
devnexen:xous_udp_fix
Jul 11, 2026
Merged

std: fix Xous UDP send_to length mismatch and truncation#158928
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
devnexen:xous_udp_fix

Conversation

@devnexen

@devnexen devnexen commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Cap the payload length to the buffer capacity so the declared length, bytes copied, and returned count agree, matching TcpStream::write.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 7, 2026
@rustbot

rustbot commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 13 candidates
  • Random selection from 6 candidates

@Mark-Simulacrum Mark-Simulacrum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with nits fixed

View changes since this review

let len_bytes = (len as u16).to_le_bytes();
tx_req.raw[19] = len_bytes[0];
tx_req.raw[20] = len_bytes[1];
for (&s, d) in buf.iter().zip(tx_req.raw[21..].iter_mut()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace this with a copy_from_slice?

}
let len = buf.len() as u16;
let len_bytes = len.to_le_bytes();
let len = buf.len().min(tx_req.raw.len() - 21);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you extract 21 here and just below to a let header_len = 21 or something like that?

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 9, 2026
@rustbot

rustbot commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 9, 2026
Cap the payload length to the buffer capacity so the declared length,
bytes copied, and returned count agree, matching TcpStream::write.
@devnexen

devnexen commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 9, 2026

@Mark-Simulacrum Mark-Simulacrum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors

rust-bors Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 54bf52f has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 11, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 11, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #159126 (Fix PR number in bootstrap's change tracker)
 - #155811 (Include AtomicU128/AtomicI128 in docs for any target)
 - #156968 (diagnostics: suggest generic_const_args for const ops)
 - #159012 (Shrink mir::Statement to 40 bytes)
 - #156618 (rustdoc: test ignoring rustc lints in CLI)
 - #158182 (std: use `OnceLock` for SGX argument storage)
 - #159114 (Add regression test for $-prefixed fragment specifier in repetition)
 - #158523 (Fix feature gate for `repr(simd)`)
 - #158876 (Fix multiple logic bugs in `Arc::make_mut`)
 - #158928 (std: fix Xous UDP send_to length mismatch and truncation)
 - #159060 (Look for the cdb architecture that corresponds to the target triple)
 - #159089 (riscv: update c-variadic test for LLVM changes)
 - #159093 (pretty-print: use inline asm's actual macro name)
 - #159122 (doc: use ptr::addr in offset_from docs)

Failed merges:

 - #158732 (Apply MCP 1003 and move diagnostics.rs into its own module)
@rust-bors
rust-bors Bot merged commit 2666ceb into rust-lang:main Jul 11, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 11, 2026
rust-timer added a commit that referenced this pull request Jul 11, 2026
Rollup merge of #158928 - devnexen:xous_udp_fix, r=Mark-Simulacrum

std: fix Xous UDP send_to length mismatch and truncation

Cap the payload length to the buffer capacity so the declared length, bytes copied, and returned count agree, matching TcpStream::write.
@workingjubilee workingjubilee added the O-xous OS: A microkernel OS for privacy in computing label Jul 19, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 22, 2026
std: fix Xous UDP recv length over-report and OOB panic

recv_inner returned the datagram length instead of the bytes copied into the caller's buffer, and rxlen >= 4075 could index past the receive buffer and panic. Clamp the count to both buffers, as in rust-lang#158928.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 22, 2026
std: fix Xous UDP recv length over-report and OOB panic

recv_inner returned the datagram length instead of the bytes copied into the caller's buffer, and rxlen >= 4075 could index past the receive buffer and panic. Clamp the count to both buffers, as in rust-lang#158928.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 22, 2026
std: fix Xous UDP recv length over-report and OOB panic

recv_inner returned the datagram length instead of the bytes copied into the caller's buffer, and rxlen >= 4075 could index past the receive buffer and panic. Clamp the count to both buffers, as in rust-lang#158928.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 22, 2026
std: fix Xous UDP recv length over-report and OOB panic

recv_inner returned the datagram length instead of the bytes copied into the caller's buffer, and rxlen >= 4075 could index past the receive buffer and panic. Clamp the count to both buffers, as in rust-lang#158928.
rust-timer added a commit that referenced this pull request Jul 23, 2026
Rollup merge of #159523 - devnexen:xous_upd_fix_2, r=Darksonn

std: fix Xous UDP recv length over-report and OOB panic

recv_inner returned the datagram length instead of the bytes copied into the caller's buffer, and rxlen >= 4075 could index past the receive buffer and panic. Clamp the count to both buffers, as in #158928.
moabo3li pushed a commit to moabo3li/miri that referenced this pull request Jul 23, 2026
std: fix Xous UDP recv length over-report and OOB panic

recv_inner returned the datagram length instead of the bytes copied into the caller's buffer, and rxlen >= 4075 could index past the receive buffer and panic. Clamp the count to both buffers, as in rust-lang/rust#158928.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-xous OS: A microkernel OS for privacy in computing S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants