Index | Thread | Search

From:
Alexander Bluhm <bluhm@openbsd.org>
Subject:
Re: sorflush(): move buffer zeroing out of socket lock
To:
Vitaliy Makkoveev <mvs@openbsd.org>
Cc:
tech@openbsd.org
Date:
Sun, 26 Jan 2025 18:35:34 +0100

Download raw body.

Thread
On Sun, Jan 26, 2025 at 01:26:56PM +0300, Vitaliy Makkoveev wrote:
> Only socantrcvmore() requires socket lock, the rest relies on buffer
> locks. Previously, some sockets were designed for socket lock only, so
> I intentionally kept it for the entire path to avoid dances around
> SB_MTXLOCK. This is not necessary now.

OK bluhm@

> Index: sys/kern/uipc_socket.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/uipc_socket.c,v
> retrieving revision 1.364
> diff -u -p -r1.364 uipc_socket.c
> --- sys/kern/uipc_socket.c	23 Jan 2025 10:44:13 -0000	1.364
> +++ sys/kern/uipc_socket.c	26 Jan 2025 10:13:26 -0000
> @@ -1278,13 +1278,13 @@ sorflush(struct socket *so)
>  
>  	solock_shared(so);
>  	socantrcvmore(so);
> +	sounlock_shared(so);
>  	mtx_enter(&sb->sb_mtx);
>  	m = sb->sb_mb;
>  	memset(&sb->sb_startzero, 0,
>  	     (caddr_t)&sb->sb_endzero - (caddr_t)&sb->sb_startzero);
>  	sb->sb_timeo_nsecs = INFSLP;
>  	mtx_leave(&sb->sb_mtx);
> -	sounlock_shared(so);
>  	sbunlock(sb);
>  
>  	if (pr->pr_flags & PR_RIGHTS && pr->pr_domain->dom_dispose)