Fix note_syscall_leave_s to avoid unaligned access #2005
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Currently
struct note_syscall_leave_s
contains a member of uintptr_t (nsc_result).Because note struct is stored with packed in the buffer, nsc_result may placed on unaligned address.
If the processor architecture doesn't support unaligned word access (ex. Cortex-M0), accessing nsc_result may crash.
This PR fixes the member nsc_result to uint8_t array like nc_pid and nc_systime.
Additionally this PR fixes similar problem in
struct note_spinlock_s
.Impact
struct note_syscall_leave_s
andstruct note_spinlock_s
are changed. All app codes using them must be fixed.(Another PR for apps (apache/nuttx-apps#429) fixes them)
Testing
Tested with spresense:nsh
Because Cortex-M4 supports unaligned access by default, I have intentionally modified CPU control register to disable unaligned access for test.
This crashes "trace dump" command. The PR fixes it.