Test "nonexistent" in psa its suite causes NULL p_data to propagate to fwrite in psa_its_set #203
Labels
No labels
api-spec
bug
CLA requested
CLA valid
compliance
DO NOT MERGE
duplicate
enhancement
feature branch
good first issue
HEADER FORMATTING ISSUE
help wanted
Information
invalid
Jira status: AWAITING REVIEW
Jira status: CLOSED
Jira status: DONE
Jira status: IN PROGRESS
Jira status: IN REVIEW
Jira status: OPEN
Jira status: REOPENED
Jira status: RESOLVED
mirrored
mirror internally
needs: backports
needs: ci
needs: design review
needs: preceding PR
needs: review
needs: work
notabug
open for community contribution
Product Backlog
question
ready for merge
security
stale
type: bug
type: enhancement
type: question
web pages
wontfix
writing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-ARMmbed/mbed-crypto#203
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Mbed Crypto 1.1.1
Toolchain GCC 9.1.1
Target Linux 5.1.20 x86_64 (Fedora 30 5.1.20-300)
Test
https://github.com/ARMmbed/mbed-crypto/blob/mbedcrypto-1.1.1/tests/suites/test_suite_psa_its.function#L167
will propagate NULL p_data to fwrite
https://github.com/ARMmbed/mbed-crypto/blob/mbedcrypto-1.1.1/library/psa_its_file.c#L212
which must not be NULL. This is reproduced with appending sanitizer flags -fsanitize=address,undefined flags to CFLAGS in library/Makefile and tests/Makefile and building and running the tests with sanitizers enabled.
Issue request type
Internal Jira reference: https://jira.arm.com/browse/IOTCRYPT-850
ends up calling
psa_its_set( uid, 0, NULL, 0 ). Since the buffer size is 0,NULLis a valid buffer pointer.The C standard doesn't see it that way (at least for
mem*functions, NULL/0 is UB; for stdio functions, it doesn't seem to be specified). So we should indeed avoid callingfwritein this case.Oddly, we do test with Asan and our CI is passing. But I can reproduce the failure locally with gcc5 and
make CFLAGS='-O2 -fsanitize=address,undefined'. So we should figure out what options we're using, and tweak or add to the CI job.Ok, I understand why CI is passing. I thought we always used Asan and UBsan together (
-fsanitize=address,undefined), but inCMakelists.txt, we activate UBSan with Clang but not with GCC. And we only run that test with ASan on CI through cmake with GCC, so we don't run it with UBSan. https://github.com/ARMmbed/mbedtls/issues/2780Created a PR here: https://github.com/ARMmbed/mbed-crypto/pull/239
PR #239 merged with a fix for this.