Index | Thread | Search

From:
Alexander Bluhm <bluhm@openbsd.org>
Subject:
Re: filt_sow{modify,process}(): don't take netlock
To:
Vitaliy Makkoveev <mvs@openbsd.org>
Cc:
tech@openbsd.org
Date:
Fri, 31 Jan 2025 16:30:25 +0100

Download raw body.

Thread
On Fri, Jan 31, 2025 at 05:17:04PM +0300, Vitaliy Makkoveev wrote:
> The `sb_mtx' mutex(9) is enough to call filt_sowrite(). The same is also
> true for filt_soexcept(), but I want to do this separately because
> filt_soexcept() shares filt_sormodify() and filt_sorprocess() with
> filt_soread().

OK bluhm@

> Index: sys/kern/uipc_socket.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/uipc_socket.c,v
> diff -u -p -r1.367 uipc_socket.c
> --- sys/kern/uipc_socket.c	30 Jan 2025 14:40:50 -0000	1.367
> +++ sys/kern/uipc_socket.c	31 Jan 2025 14:09:19 -0000
> @@ -2482,9 +2482,9 @@ filt_sowmodify(struct kevent *kev, struc
>  	struct socket *so = kn->kn_fp->f_data;
>  	int rv;
>  
> -	sofilt_lock(so, &so->so_snd);
> +	mtx_enter(&so->so_snd.sb_mtx);
>  	rv = knote_modify(kev, kn);
> -	sofilt_unlock(so, &so->so_snd);
> +	mtx_leave(&so->so_snd.sb_mtx);
>  
>  	return (rv);
>  }
> @@ -2495,9 +2495,9 @@ filt_sowprocess(struct knote *kn, struct
>  	struct socket *so = kn->kn_fp->f_data;
>  	int rv;
>  
> -	sofilt_lock(so, &so->so_snd);
> +	mtx_enter(&so->so_snd.sb_mtx);
>  	rv = knote_process(kn, kev);
> -	sofilt_unlock(so, &so->so_snd);
> +	mtx_leave(&so->so_snd.sb_mtx);
>  
>  	return (rv);
>  }