You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/10/16 15:16:22 UTC

[GitHub] [incubator-nuttx] YuuichiNakamura opened a new pull request #2005: Fix note_syscall_leave_s to avoid unaligned access

YuuichiNakamura opened a new pull request #2005:
URL: https://github.com/apache/incubator-nuttx/pull/2005


   ## 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.
   
   ## Impact
   struct note_syscall_leave_s is changed. All app codes using this must be fixed.
   (Another PR for apps will be issued.)
   
   ## 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.
   ```
   nsh> mw 0xe000e014=0x208
   ```
   This crashes "trace dump" command. The PR fixes it.
   
   
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2005: Fix note_syscall_leave_s to avoid unaligned access

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #2005:
URL: https://github.com/apache/incubator-nuttx/pull/2005#discussion_r506604786



##########
File path: include/nuttx/sched_note.h
##########
@@ -286,9 +286,9 @@ struct note_syscall_enter_s
 
 struct note_syscall_leave_s
 {
-  struct note_common_s nsc_cmn; /* Common note parameters */
-  uintptr_t nsc_result;         /* Result of the system call */
-  uint8_t nsc_nr;               /* System call number */
+  struct note_common_s nsc_cmn;          /* Common note parameters */
+  uint8_t nsc_nr;                        /* System call number */
+  uint8_t nsc_result[sizeof(uintptr_t)]; /* Result of the system call */

Review comment:
       should we fix nsp_spinlock in note_spinlock_s too?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #2005: Fix note_syscall_leave_s to avoid unaligned access

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #2005:
URL: https://github.com/apache/incubator-nuttx/pull/2005


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org