This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 94f9307a8cfd06f38c64b0c94de876f0a975fad6
Author: yangjianqing <[email protected]>
AuthorDate: Tue May 26 14:44:36 2026 +0800

    net/udp: serialize NETDEV_DOWN write_q release
    
    NETDEV_DOWN reaches sendto_eventhandler via devif_dev_event() which
    iterates dev->d_devcb without conn pointer, so the caller cannot
    acquire conn_lock. Without it, sendto_writebuffer_release() concurrently
    dequeues and frees wrb against psock_udp_sendto's 
udp_wrbuffer_inqueue_size()
    walk, leading to KASAN use-after-free on conn->write_q.
    
    Take conn_lock once conn is recovered from pvpriv to serialize against
    user-side write_q accessors that already hold conn_lock.
    
    Signed-off-by: yangjianqing <[email protected]>
---
 net/udp/udp_sendto_buffered.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/udp/udp_sendto_buffered.c b/net/udp/udp_sendto_buffered.c
index 2bb30e715f4..ce5cd5069ca 100644
--- a/net/udp/udp_sendto_buffered.c
+++ b/net/udp/udp_sendto_buffered.c
@@ -405,7 +405,9 @@ static uint32_t sendto_eventhandler(FAR struct net_driver_s 
*dev,
        * the next transfer.
        */
 
+      conn_lock(&conn->sconn);
       sendto_writebuffer_release(conn, NULL);
+      conn_unlock(&conn->sconn);
       return flags;
     }
 

Reply via email to