Skip to content

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

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

std: fix Xous UDP recv length over-report and OOB panic#159523
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
devnexen:xous_upd_fix_2

Conversation

@devnexen

@devnexen devnexen commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

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.

@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 18, 2026
@rustbot

rustbot commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

r? @Darksonn

rustbot has assigned @Darksonn.
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

@rustbot

This comment has been minimized.

@workingjubilee workingjubilee added the O-xous OS: A microkernel OS for privacy in computing label Jul 19, 2026
@workingjubilee

Copy link
Copy Markdown
Member

Can you address the thing that rustbot mentioned?

Comment on lines 183 to 185
for (&s, d) in rr[22..22 + max].iter().zip(buf.iter_mut()) {
*d = s;
}

@Darksonn Darksonn Jul 21, 2026

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.

Could we do this?

Suggested change
for (&s, d) in rr[22..22 + max].iter().zip(buf.iter_mut()) {
*d = s;
}
buf.copy_from_slice(&rr[22..22 + max]);

And if so, then what about this?

Suggested change
for (&s, d) in rr[22..22 + max].iter().zip(buf.iter_mut()) {
*d = s;
}
buf.copy_from_slice(&rr[22..][..max]);

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good point albeit I took a slightly different approach as both slices would need to be of the same length.

@Darksonn

Copy link
Copy Markdown
Member

@rustbot author

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

rustbot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

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

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, mirroring the earlier
send_to fix.
@devnexen

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 21, 2026
@Darksonn

Copy link
Copy Markdown
Member

Can we add a test for this? I'm not sure if we run tests for this target.

@devnexen

Copy link
Copy Markdown
Contributor Author

Can we add a test for this? I'm not sure if we run tests for this target.

Nope, it is tier 3, no CI job, and the target docs say the test suite isn't supported. The module is gated on target_os = "xous", so a test there would never be compiled, and the buffer comes straight from a lend_mut syscall.

@Darksonn Darksonn 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 22, 2026

Copy link
Copy Markdown
Contributor

📌 Commit bb4f000 has been approved by Darksonn

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 22, 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.
rust-bors Bot pushed a commit that referenced this pull request Jul 23, 2026
Rollup of 8 pull requests

Successful merges:

 - #159504 (Abort const-eval queries early when there are generics in the type)
 - #159523 (std: fix Xous UDP recv length over-report and OOB panic)
 - #159605 (Add fallback for `intrinsics::fabs`)
 - #159699 (bump std libc to 0.2.189)
 - #159306 (Add new variant to iterating-updating-mutref borrowck test)
 - #159346 (fs::hard_link: use linkat on Android)
 - #159513 (Consider `()` as suspicious only when expecting `!` for runtime symbols)
 - #159734 (Document the link_section attribute)
@rust-bors
rust-bors Bot merged commit f42a267 into rust-lang:main Jul 23, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 23, 2026
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
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#159504 (Abort const-eval queries early when there are generics in the type)
 - rust-lang/rust#159523 (std: fix Xous UDP recv length over-report and OOB panic)
 - rust-lang/rust#159605 (Add fallback for `intrinsics::fabs`)
 - rust-lang/rust#159699 (bump std libc to 0.2.189)
 - rust-lang/rust#159306 (Add new variant to iterating-updating-mutref borrowck test)
 - rust-lang/rust#159346 (fs::hard_link: use linkat on Android)
 - rust-lang/rust#159513 (Consider `()` as suspicious only when expecting `!` for runtime symbols)
 - rust-lang/rust#159734 (Document the link_section attribute)
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