Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

[Bug 17097] libfoundation: Add MCMemoryClearSecure()#5338

Merged
peter-b merged 2 commits into
livecode:developfrom
peter-b:bugfix-17097
Apr 5, 2017
Merged

[Bug 17097] libfoundation: Add MCMemoryClearSecure()#5338
peter-b merged 2 commits into
livecode:developfrom
peter-b:bugfix-17097

Conversation

@peter-b

@peter-b peter-b commented Apr 4, 2017

Copy link
Copy Markdown
Contributor

Add a new function, MCMemoryClearSecure(), that's equivalent to
MCMemoryClear() but with the guarantee that it will never be
optimised out.

On Windows, this uses the standard SecureZeroMemory() library
function.

On other platforms, this uses MCMemoryClear() (i.e. memset()), but
with an additional memory barrier that prevents the call to memset()
from being optimised out. Typical assembly generated in Release
mode:

push	rbx
mov	rdx, rsi
xor	esi, esi
mov	rbx, rdi
call	memset
pop	rbx
ret

peter-b added 2 commits April 1, 2017 08:17
Add a new function, `MCMemoryClearSecure()`, that's equivalent to
`MCMemoryClear()` but with the guarantee that it will never be
optimised out.

On Windows, this uses the standard `SecureZeroMemory()` library
function.

On other platforms, this uses `MCMemoryClear()` (i.e. `memset()`), but
with an additional memory barrier that prevents the call to `memset()`
from being optimised out.  Typical assembly generated in `Release`
mode:

    push	rbx
    mov	rdx, rsi
    xor	esi, esi
    mov	rbx, rdi
    call	memset
    pop	rbx
    ret
Add templates for securely zeroing single objects and object spans.
@peter-b peter-b added this to the 9.0.0-dp-7 milestone Apr 4, 2017
@mention-bot

Copy link
Copy Markdown

@peter-b, thanks for your PR! By analyzing the history of the files in this pull request, we identified @livecodeian, @runrevmark and @livecodesebastien to be potential reviewers.

@runrevmark

Copy link
Copy Markdown
Contributor

@livecode-vulcan review ok 8ceb1c6

@livecode-vulcan

Copy link
Copy Markdown
Contributor

💙 review by @runrevmark ok 8ceb1c6

@livecode-vulcan

Copy link
Copy Markdown
Contributor

😞 test failure 8ceb1c6

  • try-community-armv6-android-api8: success
  • try-community-armv6-android-api9: success
  • try-community-js-emscripten-sdk1.35: success
  • try-community-universal-ios-iphoneos10.2: success
  • try-community-universal-ios-iphonesimulator10.2: success
  • try-community-universal-mac-macosx10.6: success
  • try-community-universal-mac-macosx10.9: success
  • try-community-x86-linux-debian7: success
  • try-community-x86-linux-debian8: success
  • try-community-x86_64-linux-debian7: success
  • try-community-x86_64-linux-debian8: success
  • try-community-x86-win32: failure
  • try-community-x86_64-win32: pending

@peter-b

peter-b commented Apr 4, 2017

Copy link
Copy Markdown
Contributor Author

@runrevmark I've now tweaked this PR to include Windows.h into foundation-core.cpp, so that SecureZeroMemory() is defined.

@runrevmark

Copy link
Copy Markdown
Contributor

@livecode-vulcan review ok 5fc6212

@peter-b

peter-b commented Apr 4, 2017

Copy link
Copy Markdown
Contributor Author

@runrevmark I think you had the wrong SHA-1...!

@livecode-vulcan review by @runrevmark fc21e2b

@runrevmark

Copy link
Copy Markdown
Contributor

@livecode-vulcan review ok fc21e2b

@livecode-vulcan

Copy link
Copy Markdown
Contributor

💙 review by @runrevmark ok fc21e2b

livecode-vulcan added a commit that referenced this pull request Apr 5, 2017
[Bug 17097] libfoundation: Add MCMemoryClearSecure()

Add a new function, `MCMemoryClearSecure()`, that's equivalent to
`MCMemoryClear()` but with the guarantee that it will never be
optimised out.

On Windows, this uses the standard `SecureZeroMemory()` library
function.

On other platforms, this uses `MCMemoryClear()` (i.e. `memset()`), but
with an additional memory barrier that prevents the call to `memset()`
from being optimised out.  Typical assembly generated in `Release`
mode:

```asm
push	rbx
mov	rdx, rsi
xor	esi, esi
mov	rbx, rdi
call	memset
pop	rbx
ret
```
@livecode-vulcan

Copy link
Copy Markdown
Contributor

😞 test failure fc21e2b

  • try-community-armv6-android-api8: success
  • try-community-armv6-android-api9: success
  • try-community-js-emscripten-sdk1.35: success
  • try-community-universal-ios-iphoneos10.2: success
  • try-community-universal-ios-iphonesimulator10.2: success
  • try-community-universal-mac-macosx10.6: success
  • try-community-universal-mac-macosx10.9: success
  • try-community-x86-linux-debian7: success
  • try-community-x86-linux-debian8: success
  • try-community-x86_64-linux-debian7: success
  • try-community-x86_64-linux-debian8: success
  • try-community-x86-win32: failure
  • try-community-x86_64-win32: pending

@peter-b

peter-b commented Apr 5, 2017

Copy link
Copy Markdown
Contributor Author

@runrevmark Fixed think-o misspelling of size as cnt in Windows implementation. I think your review continues to apply. 😉

@livecode-vulcan review by @runrevmark ok 9d132a2

@livecode-vulcan

Copy link
Copy Markdown
Contributor

💙 review by @runrevmark ok 9d132a2

livecode-vulcan added a commit that referenced this pull request Apr 5, 2017
[Bug 17097] libfoundation: Add MCMemoryClearSecure()

Add a new function, `MCMemoryClearSecure()`, that's equivalent to
`MCMemoryClear()` but with the guarantee that it will never be
optimised out.

On Windows, this uses the standard `SecureZeroMemory()` library
function.

On other platforms, this uses `MCMemoryClear()` (i.e. `memset()`), but
with an additional memory barrier that prevents the call to `memset()`
from being optimised out.  Typical assembly generated in `Release`
mode:

```asm
push	rbx
mov	rdx, rsi
xor	esi, esi
mov	rbx, rdi
call	memset
pop	rbx
ret
```
@livecode-vulcan

Copy link
Copy Markdown
Contributor

😎 test success 9d132a2

  • try-community-armv6-android-api8: success
  • try-community-armv6-android-api9: success
  • try-community-js-emscripten-sdk1.35: success
  • try-community-universal-ios-iphoneos10.2: success
  • try-community-universal-ios-iphonesimulator10.2: success
  • try-community-universal-mac-macosx10.6: success
  • try-community-universal-mac-macosx10.9: success
  • try-community-x86-linux-debian7: success
  • try-community-x86-linux-debian8: success
  • try-community-x86_64-linux-debian7: success
  • try-community-x86_64-linux-debian8: success
  • try-community-x86-win32: success
  • try-community-x86_64-win32: success

@peter-b peter-b merged commit 5f7d7a8 into livecode:develop Apr 5, 2017
@peter-b peter-b deleted the bugfix-17097 branch April 5, 2017 10:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants