Skip to content
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

Default mode does not illustrate a spectre attack sometimes #22

Open
profolsen opened this issue May 22, 2021 · 0 comments
Open

Default mode does not illustrate a spectre attack sometimes #22

profolsen opened this issue May 22, 2021 · 0 comments

Comments

@profolsen
Copy link

profolsen commented May 22, 2021

the if on line 31 succeeds if x is negative. This is a problem if the compiler puts secret at a lower address than array1, which is the case on my Mac (the offset calculation in main will make malicious_x and therefore x negative). In this case, the program doesn't actually demonstrate a spectre attack. The fix would be to check that x is both greater than or equal to zero and less than array1_size. I'm not sure how to do that without causing branching (I guess that using && must cause branching because of short-circuiting and will mess up branch prediction. Would something like "...int test = x < array1_size; test &= x >= 0; if(test) ..." work?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant