Skip to content

std: simplify SGX's UnsafeList - #161060

Open
joboet wants to merge 1 commit into
rust-lang:mainfrom
joboet:sgx_unsafe_list
Open

std: simplify SGX's UnsafeList#161060
joboet wants to merge 1 commit into
rust-lang:mainfrom
joboet:sgx_unsafe_list

Conversation

@joboet

@joboet joboet commented Aug 13, 2026

Copy link
Copy Markdown
Member

Fixes #160603
Fixes #114581

This fixes the soundness issues in SGX's UnsafeList by removing the use of a dummy node in the doubly-linked list, which would have required either UnsafePinned or pointer laundering tricks to make sound (c.f. #160641). In addition, the code is now much more careful when it comes to creating mutable references to whole entries to avoid invalidating any shared borrows of the values when modifying lists.

CC @jethrogb

@rustbot rustbot added O-SGX Target: SGX 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 Aug 13, 2026
@rustbot

rustbot commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

r? @clarfonthey

rustbot has assigned @clarfonthey.
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 ChrisDenton, JohnTitor, Mark-Simulacrum, clarfonthey, nia-e

@jethrogb

Copy link
Copy Markdown
Contributor

This is a very intrusive change that changes a lot about the inner workings of the list as well as the list API. I don't really support making this kind of change.

@joboet

joboet commented Aug 13, 2026

Copy link
Copy Markdown
Member Author

Given that both UnsafeList and WaitQueue are private I don't see how this would be a problem?

@jethrogb

Copy link
Copy Markdown
Contributor

The problem is that this needs to be very carefully designed and reviewed because it can easily lead to fundamental concurrency issues if there are any bugs. I don't see a good reason for such an intrusive change given there are much simpler fixes.

@theemathas

Copy link
Copy Markdown
Contributor

I consider the pointer provenance laundering stuff to be a very complicated fix, so I don't think the "there are much simpler fixes" argument really holds.

@jethrogb

Copy link
Copy Markdown
Contributor

The entire code can be reviewed and fully understood assuming launder is a no-op.

@ds84182

ds84182 commented Aug 16, 2026

Copy link
Copy Markdown

The entire code can be reviewed and fully understood assuming launder is a no-op.

Launder is a runtime no-op, but is very significant at compile time as any issues with it will lead to silent miscompilations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-SGX Target: SGX 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SGX UnsafeList is unsound, WaitQueue can execute UB Miri violation in std/src/sys/sgx/waitqueue/unsafe_list.rs

6 participants