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

Fix -fsanitize=undefined diagnostics #6

Closed

Conversation

jepler
Copy link

@jepler jepler commented May 10, 2021

Fixes the following diagnostics:

bigint.c:631:39: runtime error: left shift of 162 by 24 places cannot be represented in type 'int'
sha1.c:124:42: runtime error: left shift of 152 by 24 places cannot be represented in type 'int'

Directs the sanitizer not to instrument the function where this diagnostic otherwise occurs:

crypto_misc.c:131:5: runtime error: load of address 0x7ffd83a8633c with insufficient space for an object of type 'unsigned char'

.. this function deliberately reads memory in a way that is undefined under the C standard, but is a semi-recognized technique to maybe supplement a CSPRNG entropy pool; blindly removing it is the riskier option, a la https://www.debian.org/security/2008/dsa-1571

These changes fix all the problems seen in axtls when running the testsuite of a popular embedded python implementation on a linux amd64 desktop with gcc 8.3.0 -fsanitize=undefined.

I don't know your branching policy in this repo, so feel free to close if this is not something you're interested in taking, or let me know which branch I should be working relative to so I can re-spin if necessary.

Fixes the following diagnostics:
```
bigint.c:631:39: runtime error: left shift of 162 by 24 places cannot be represented in type 'int'
sha1.c:124:42: runtime error: left shift of 152 by 24 places cannot be represented in type 'int'
```

Directs the sanitizer not to instrument the function where this diagnostic
otherwise occurs:
```
crypto_misc.c:131:5: runtime error: load of address 0x7ffd83a8633c with insufficient space for an object of type 'unsigned char'
```
.. this function deliberately reads memory in a way that is undefined
under the C standard, but is a semi-recognized technique to maybe supplement
a CSPRNG entropy pool; blindly removing it is the riskier option, a la
https://www.debian.org/security/2008/dsa-1571

These changes fix all the problems seen in axtls when running the testsuite
of a popular embedded python implementation on a linux amd64 desktop
with gcc 8.3.0 -fsanitize=undefined.
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

Successfully merging this pull request may close these issues.

None yet

1 participant