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

   ## Summary                                                                   
  
                                                                                
  
   Fix interrupted file I/O handling in `rammap()` and `msync_rammap()`.        
  
                                                                                
  
   When `file_read()` or `file_write()` returned `-EINTR`, the code treated the 
  
   operation as retryable but still advanced the data buffer and reduced the    
  
   remaining length afterwards.                                                 
  
                                                                                
  
   Since `-EINTR` is negative, this could move the buffer pointer backwards and 
  
   increase the remaining length, potentially causing incorrect retries, an     
  
   infinite loop, or out-of-bounds memory access.                               
  
                                                                                
  
   ## Changes                                                                   
  
                                                                                
  
   - Retry interrupted `file_write()` calls in `msync_rammap()` without 
updating  
     the write buffer or remaining length.                                      
  
   - Retry interrupted `file_read()` calls in `rammap()` without updating the 
read
     buffer or remaining length.                                                
  
   - Keep existing behavior for non-`EINTR` read/write errors.                  
  
   
   ## Testing
   
   sim/nsh


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