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

   ## Summary                                                                
                                                                             
   Fix the `recvfrom()` user buffer copyout size in kernel builds.           
                                                                             
   When `CONFIG_BUILD_KERNEL` is enabled, `recvfrom()` receives data into a  
   temporary kernel buffer before copying the result back to the user buffer.
   The previous code copied the full requested length (`len`) regardless of  
   how many bytes were actually received.                                    
                                                                             
   For short receives, this could copy uninitialized bytes from the temporary
   kernel buffer back to user space.                                         
                                                                             
   This change copies data back only when bytes were received, and limits the
   copyout length to the actual return value from `psock_recvfrom()`.        
                                                                             
   It also avoids copying the source address back to user space when the     
   receive operation failed.                                                 
                                                                             
   ## Impact                                                                 
                                                                             
   - Prevents copying uninitialized kernel-buffer bytes on short receives.   
   - Avoids user address copyout on failed receives.                         
   - Affects only `CONFIG_BUILD_KERNEL` builds.                              
   - Non-kernel builds are unchanged.                                        
                                                                             
   ## Testing                                                                
   
   rv-virt/netnsh64


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