git: 7a019565ff6d - stable/14 - uipc_socket: handle socket buffer locks in sopeeloff

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Wed, 17 Apr 2024 13:58:47 UTC
The branch stable/14 has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=7a019565ff6dc6efb5c6ab091343740fd6dd0377

commit 7a019565ff6dc6efb5c6ab091343740fd6dd0377
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2024-04-05 16:14:54 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2024-04-17 13:58:22 +0000

    uipc_socket: handle socket buffer locks in sopeeloff
    
    PR:                     278171
    Reviewed by:            markj
    Fixes:                  a4fc41423f7d ("sockets: enable protocol specific socket buffers")
    Differential Revision:  https://reviews.freebsd.org/D44640
    
    (cherry picked from commit 681711b77cde2cf3d64dc1e4951ec8287bc4f3e8)
---
 sys/kern/uipc_socket.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 880dec89245b..5faf018dca11 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -924,6 +924,10 @@ sopeeloff(struct socket *head)
 	so->so_snd.sb_timeo = head->so_snd.sb_timeo;
 	so->so_rcv.sb_flags |= head->so_rcv.sb_flags & SB_AUTOSIZE;
 	so->so_snd.sb_flags |= head->so_snd.sb_flags & SB_AUTOSIZE;
+	if ((so->so_proto->pr_flags & PR_SOCKBUF) == 0) {
+		so->so_snd.sb_mtx = &so->so_snd_mtx;
+		so->so_rcv.sb_mtx = &so->so_rcv_mtx;
+	}
 
 	soref(so);