Skip to content

Use the updated buffer length in UEFI locate_handles - #164955

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
yashaggarwal85d:fix-uefi-locate-handles-len
Oct 26, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
yashaggarwal85d:fix-uefi-locate-handles-len

Conversation

@yashaggarwal85d

@yashaggarwal85d yashaggarwal85d commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

locate_handles was using the handle count from the first LocateHandle call when setting the
vec length, instead of the size the second call actually wrote. If handles go away between
the two calls this marks uninitialized entries as initialized. Use the updated buf_len instead.

Fixes #164945

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

rustbot commented Oct 26, 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 37 candidates
  • Random selection from ChrisDenton, JohnTitor, Mark-Simulacrum, aapoalas, thomcc

@rustbot

rustbot commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Error: Failed to set assignee to Ayush1325: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip.

@joboet

joboet commented Oct 26, 2026

Copy link
Copy Markdown
Member

Yes, this is unsound, but it's more subtle than the issue points out. UEFI does not have a way to close handles, and does not have any asynchronous callback facilities that could cause a protocol to be closed for the handle, so something like device hotplugging cannot cause an issue here. But we make a call to the global allocator in between the calls to LocateHandle – that is defined in user code and as such could conceivably make calls to CloseProtocol.

@bors r+

@rust-bors

rust-bors Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

📌 Commit adfda59 has been approved by joboet

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 Oct 26, 2026
@joboet joboet assigned joboet and unassigned Mark-Simulacrum Oct 26, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 26, 2026
…ndles-len, r=joboet

Use the updated buffer length in UEFI locate_handles

locate_handles was using the handle count from the first LocateHandle call when setting the
vec length, instead of the size the second call actually wrote. If handles go away between
the two calls this marks uninitialized entries as initialized. Use the updated buf_len instead.

Fixes rust-lang#164945
rust-bors Bot pushed a commit that referenced this pull request Oct 26, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #164955 (Use the updated buffer length in UEFI locate_handles)
 - #164958 (uefi: roll back env changes when `start_image` fails)
 - #164968 (thread_local::guard: update comments a bit)
 - #164303 (Remove the 'sub' method from 'At' and migrate to 'sub_raw')
 - #164674 (Use a NoSpan marker for region constraints without spans)
 - #164856 (Switch from `insta` to `expect-test` in bootstrap)
 - #164934 (Remove redundant vec and duplicate indexing in find_noop_landing_pads)
 - #164954 (Reduce `SpanData` use)
rust-bors Bot pushed a commit that referenced this pull request Oct 26, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #164955 (Use the updated buffer length in UEFI locate_handles)
 - #164958 (uefi: roll back env changes when `start_image` fails)
 - #164968 (thread_local::guard: update comments a bit)
 - #164303 (Remove the 'sub' method from 'At' and migrate to 'sub_raw')
 - #164674 (Use a NoSpan marker for region constraints without spans)
 - #164934 (Remove redundant vec and duplicate indexing in find_noop_landing_pads)
 - #164954 (Reduce `SpanData` use)
 - #164970 (`rust-analyzer` subtree update)
rust-bors Bot pushed a commit that referenced this pull request Oct 26, 2026
Rollup merge of #164955 - yashaggarwal85d:fix-uefi-locate-handles-len, r=joboet

Use the updated buffer length in UEFI locate_handles

locate_handles was using the handle count from the first LocateHandle call when setting the
vec length, instead of the size the second call actually wrote. If handles go away between
the two calls this marks uninitialized entries as initialized. Use the updated buf_len instead.

Fixes #164945
@rust-bors
rust-bors Bot merged commit 493f336 into rust-lang:main Oct 26, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 26, 2026
@yashaggarwal85d

This comment was marked as low quality.

BenMac31 pushed a commit to graphide-oss/rust-analyzer that referenced this pull request Nov 2, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#164955 (Use the updated buffer length in UEFI locate_handles)
 - rust-lang/rust#164958 (uefi: roll back env changes when `start_image` fails)
 - rust-lang/rust#164968 (thread_local::guard: update comments a bit)
 - rust-lang/rust#164303 (Remove the 'sub' method from 'At' and migrate to 'sub_raw')
 - rust-lang/rust#164674 (Use a NoSpan marker for region constraints without spans)
 - rust-lang/rust#164934 (Remove redundant vec and duplicate indexing in find_noop_landing_pads)
 - rust-lang/rust#164954 (Reduce `SpanData` use)
 - rust-lang/rust#164970 (`rust-analyzer` subtree update)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

UEFI: locate_handles uses stale size for set_len, potentially exposing uninitialized handles

4 participants