git: 1e980fdf7ade - stable/14 - getsockopt: improve locking for SOL_SOCKET level socket options
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 31 Oct 2024 13:59:23 UTC
The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=1e980fdf7adee2d3ad53b29e192d134bb46d3e6c commit 1e980fdf7adee2d3ad53b29e192d134bb46d3e6c Author: Michael Tuexen <tuexen@FreeBSD.org> AuthorDate: 2024-10-07 14:46:41 +0000 Commit: Michael Tuexen <tuexen@FreeBSD.org> CommitDate: 2024-10-31 11:37:55 +0000 getsockopt: improve locking for SOL_SOCKET level socket options Ensure SOLISTENING() is done inside SOCK_LOCK()/SOCK_UNLOCK() for getsockopt() handling of SOL_SOCKET-level socket options. Reviewed by: markj, rscheff Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D46881 (cherry picked from commit 3326ab87cc22cb70a41e13aefd8684ff0feed01f) --- sys/kern/uipc_socket.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 4621339c4429..84d817c9ada1 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -4112,23 +4112,31 @@ integer: goto integer; case SO_SNDBUF: + SOCK_LOCK(so); optval = SOLISTENING(so) ? so->sol_sbsnd_hiwat : so->so_snd.sb_hiwat; + SOCK_UNLOCK(so); goto integer; case SO_RCVBUF: + SOCK_LOCK(so); optval = SOLISTENING(so) ? so->sol_sbrcv_hiwat : so->so_rcv.sb_hiwat; + SOCK_UNLOCK(so); goto integer; case SO_SNDLOWAT: + SOCK_LOCK(so); optval = SOLISTENING(so) ? so->sol_sbsnd_lowat : so->so_snd.sb_lowat; + SOCK_UNLOCK(so); goto integer; case SO_RCVLOWAT: + SOCK_LOCK(so); optval = SOLISTENING(so) ? so->sol_sbrcv_lowat : so->so_rcv.sb_lowat; + SOCK_UNLOCK(so); goto integer; case SO_SNDTIMEO: @@ -4185,15 +4193,21 @@ integer: break; case SO_LISTENQLIMIT: + SOCK_LOCK(so); optval = SOLISTENING(so) ? so->sol_qlimit : 0; + SOCK_UNLOCK(so); goto integer; case SO_LISTENQLEN: + SOCK_LOCK(so); optval = SOLISTENING(so) ? so->sol_qlen : 0; + SOCK_UNLOCK(so); goto integer; case SO_LISTENINCQLEN: + SOCK_LOCK(so); optval = SOLISTENING(so) ? so->sol_incqlen : 0; + SOCK_UNLOCK(so); goto integer; case SO_TS_CLOCK: