Uh oh!
There was an error while loading. Please reload this page.
Implement read_buf and vectored read/write for SGX stdio - #137355
Conversation
rustbot
commented
Feb 21, 2025
r? @ChrisDenton rustbot has assigned @ChrisDenton. Use |
jethrogb
commented
Feb 25, 2025
| /// # Panics | ||
| /// This function panics if the destination doesn't have the same length as | ||
| /// the source. | ||
| pub fn copy_to_enclave_uninit(&self, dest: &mut [MaybeUninit<T>]) { |
There was a problem hiding this comment.
Needing this “feels” wrong to me. You could do impl<T: UserSafeSized> UserSafeSized for MaybeUninit<T> and then just create a [MaybeUninit<u8>] in read_buf. However, of course the whole point of UserSafe is that you want to explicitly assume everything you copy out of userspace is initialized, so that would kind of defeat the point.
There was a problem hiding this comment.
If both of those options are unsatisfying to you, what would you recommend I do so this can impl read_buf?
This was explicitly requested by the T-libs reviewer. |
thaliaarchi
commented
Feb 25, 2025
I'm fine with reverting my change to this. Since |
b81e9d2 to
4cfdd68Comparethaliaarchi
commented
Feb 26, 2025
I noticed that |
jethrogb
commented
Feb 27, 2025
Perhaps |
I think the two would actually be better coexisting, since they serve slightly different purposes. |
How about this? // SAFETY: Requires that `T` is contained within `Self` using transparent representationunsafetraitUserSafeCopyDestination<T: ?Sized>{fnas_mut_ptr(&mutself) -> *mutT;}unsafeimpl<T>UserSafeCopyDestination<T>forT{fnas_mut_ptr(&mutself) -> *mutT{selfas_}}unsafeimpl<T>UserSafeCopyDestination<[T]>for[T]{fnas_mut_ptr(&mutself) -> *mut[T]{selfas_}}unsafeimpl<T>UserSafeCopyDestination<T>forMaybeUninit<T>{fnas_mut_ptr(&mutself) -> *mutT{selfas*mutSelfas_}}unsafeimpl<T>UserSafeCopyDestination<[T]>for[MaybeUninit<T>]{fnas_mut_ptr(&mutself) -> *mut[T]{selfas*mutSelfas_}}impl<T: ?Sized>UserRef<T>{pubfncopy_to_enclave<V: ?Sized + UserSafeCopyDestination<T>>(&self,dest:&mutV){unsafe{assert_eq!(mem::size_of_val(dest), mem::size_of_val(&*self.0.get()));copy_from_userspace(self.0.get()as*constTas*constu8,
dest.as_mut_ptr()as*mutu8,
mem::size_of_val(dest),);}}} |
4cfdd68 to
da0fbf6CompareThat's much more flexible! I've added a commit with your patch, which I attributed to you. You might want to double-check that the metadata looks good. (FYI, it looks like your fortanix.com email isn't connected to your GitHub account, so you're not linked.) |
And since we've been talking about SGX copying APIs, I think That would be a breaking change, but I see no use of it outside of |
bors
commented
Mar 7, 2025
☔ The latest upstream changes (presumably #138155) made this pull request unmergeable. Please resolve the merge conflicts. |
da0fbf6 to
0ec7397CompareCo-authored-by: Thalia Archibald <thalia@archibald.dev>
0ec7397 to
d34c289Comparethaliaarchi
commented
Mar 10, 2025
e80df9c to
c62aa0bComparethaliaarchi
commented
Mar 12, 2025
I had neglected to update the |
ChrisDenton
commented
Mar 12, 2025
@bors r- |
ChrisDenton
commented
Mar 12, 2025
@bors r+ |
bors
commented
Mar 12, 2025
…x, r=ChrisDenton Implement `read_buf` and vectored read/write for SGX stdio Implement `read_buf`, `read_vectored`, and `write_vectored` for the SGX stdio types. Additionally, extend `User<T>::copy_to_enclave` to work for copying to uninitialized values and fix unsoundness in `UserRef<[T]>::copy_to_enclave_vec`. cc `@jethrogb` Tracked in rust-lang#136756
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#126856 (remove deprecated tool `rls`) - rust-lang#133981 (rustdoc-json: Refractor and document Id's) - rust-lang#136842 (Add libstd support for Trusty targets) - rust-lang#137355 (Implement `read_buf` and vectored read/write for SGX stdio) - rust-lang#137457 (fix for issue 132802: x86 code in `wasm32-unknown-unknown` binaries) - rust-lang#138162 (Update the standard library to Rust 2024) - rust-lang#138273 (metadata: Ignore sysroot when doing the manual native lib search in rustc) - rust-lang#138346 (naked functions: on windows emit `.endef` without the symbol name) - rust-lang#138370 (Simulate OOM for the `try_oom_error` test) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#126856 (remove deprecated tool `rls`) - rust-lang#133981 (rustdoc-json: Refractor and document Id's) - rust-lang#136842 (Add libstd support for Trusty targets) - rust-lang#137355 (Implement `read_buf` and vectored read/write for SGX stdio) - rust-lang#138162 (Update the standard library to Rust 2024) - rust-lang#138273 (metadata: Ignore sysroot when doing the manual native lib search in rustc) - rust-lang#138346 (naked functions: on windows emit `.endef` without the symbol name) - rust-lang#138370 (Simulate OOM for the `try_oom_error` test) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#137355 - thaliaarchi:io-optional-methods/sgx, r=ChrisDenton Implement `read_buf` and vectored read/write for SGX stdio Implement `read_buf`, `read_vectored`, and `write_vectored` for the SGX stdio types. Additionally, extend `User<T>::copy_to_enclave` to work for copying to uninitialized values and fix unsoundness in `UserRef<[T]>::copy_to_enclave_vec`. cc ``@jethrogb`` Tracked in rust-lang#136756
…x, r=ChrisDenton Implement `read_buf` and vectored read/write for SGX stdio Implement `read_buf`, `read_vectored`, and `write_vectored` for the SGX stdio types. Additionally, extend `User<T>::copy_to_enclave` to work for copying to uninitialized values and fix unsoundness in `UserRef<[T]>::copy_to_enclave_vec`. cc ``@jethrogb`` Tracked in rust-lang#136756
In rust-lang#108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that rust-lang#137355 implemented it for SGX types.
…orkingjubilee Update test for SGX now implementing `read_buf` In rust-lang#108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that rust-lang#137355 implemented it for SGX types. cc `@jethrogb`
…orkingjubilee Update test for SGX now implementing `read_buf` In rust-lang#108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that rust-lang#137355 implemented it for SGX types. cc ``@jethrogb``
…orkingjubilee Update test for SGX now implementing `read_buf` In rust-lang#108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that rust-lang#137355 implemented it for SGX types. cc `@jethrogb`
…orkingjubilee Update test for SGX now implementing `read_buf` In rust-lang#108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that rust-lang#137355 implemented it for SGX types. cc ``@jethrogb``
…orkingjubilee Update test for SGX now implementing `read_buf` In rust-lang#108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that rust-lang#137355 implemented it for SGX types. cc ```@jethrogb```
…orkingjubilee Update test for SGX now implementing `read_buf` In rust-lang#108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that rust-lang#137355 implemented it for SGX types. cc ````@jethrogb````
Rollup merge of rust-lang#138631 - thaliaarchi:sgx-read-buf-test, r=workingjubilee Update test for SGX now implementing `read_buf` In rust-lang#108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that rust-lang#137355 implemented it for SGX types. cc ````@jethrogb````
In rust-lang#108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that rust-lang#137355 implemented it for SGX types.
…orkingjubilee Update test for SGX now implementing `read_buf` In rust-lang#108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that rust-lang#137355 implemented it for SGX types. cc ````@jethrogb````
Implement
read_buf,read_vectored, andwrite_vectoredfor the SGX stdio types.Additionally, extend
User<T>::copy_to_enclaveto work for copying to uninitialized values and fix unsoundness inUserRef<[T]>::copy_to_enclave_vec.cc @jethrogb
Tracked in #136756