Zfeather914 opened a new pull request, #17811:
URL: https://github.com/apache/nuttx/pull/17811

   ## Summary
   
   issue description:
   task A:                                            NSH:
   1.open->                                           reboot->sync->task_fsfsync
   2.nx_vopen->               context switch
   3.fdlist_allocate:            ---->                
4.fsync->file_sync->assert(inode or priv is empty)
   (new fd with empty filep)
   5.file_vopen:
   (init empty filep)
   6.return fd
   
   Task A allocates a new fd with an empty filep in fdlist_allocate. Before it 
can fully initialize the filep in file_vopen, the NSH task triggers a file - 
system sync operation. The sync operation encounters the empty filep associated 
with the newly allocated fd, causing the assertion to fail and the system to 
crash.
   
   To resolve this race condition, we should modify the fd allocation process. 
Instead of allocating a new fd with an empty filep first and then initializing 
it later, we should use the file_allocate_from_inode function. This function 
allows us to initialize the file structure first and then bind it to the new 
filep when allocating the fd. By doing so, we ensure that the filep is always 
properly initialized before it is used in any file - system operations, thus 
preventing the assertion failure and the subsequent system crash.
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to