-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-8211] Support a mechanism for zeroing an UnsafeMutable{,Raw}BufferPointer #50743
Comments
|
@lorentey, think this would be a good StarterProposal? |
As a purely informational note, |
@belkadan I think so! Although, to be honest, I'm quite surprised at the current behavior. It seems that changing the second, partially duplicate initialization to |
LLVM is always allowed to remove writes that it determines are unused, so just because we don't do that optimization now doesn't mean it won't change in the future. That's why things like |
rdar://95723264 |
I don't see that on OpenRadar, so I presume it's private. Keep me posted! |
Posting the radar just communicates that it's tracked by Apple. The likeliest thing is that there's no extra information attached beyond what's in this issue. |
Additional Detail from JIRA
md5: 3a2dea04d2903bbfde833b4186202d1f
Issue Description:
Currently Swift provides no mechanism to zero a buffer of memory that is safe from the compiler "helpfully" optimising it away. The natural thing to try to do, {{ pointer.initialize(repeating: 0) }} can be elided by the compiler, as demonstrated by this short Swift program:
When compiled with optimisations turned on, the following SIL is emitted for the main function:
Note that we never call the initializer with zero. Instead we see only the initialisation with the range, and then the deallocation.
There should be some supported Swift way to securely overwrite a buffer of memory that does not involve making a call through libc. This is useful with system programs that are handling sensitive data (e.g. passphrases).
The text was updated successfully, but these errors were encountered: