On Mon, Jun 22, 2020 at 11:11:47AM +0200, Claudio Jeker wrote:
> This crashes are because of wg(4) calling the interface ioctl handler
> without holding the netlock() this is not allowed.
>
> As a quick fix this diff may work.
> --
> :wq Claudio
>
> Index: net/if.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if.c,v
> retrieving revision 1.609
> diff -u -p -r1.609 if.c
> --- net/if.c 22 Jun 2020 03:07:57 -0000 1.609
> +++ net/if.c 22 Jun 2020 09:06:42 -0000
> @@ -2220,13 +2221,6 @@ ifioctl(struct socket *so, u_long cmd, c
> break;
>
> /* don't take NET_LOCK because i2c reads take a long time */
> - error = ((*ifp->if_ioctl)(ifp, cmd, data));
> - break;
> - case SIOCSWG:
> - case SIOCGWG:
> - /* Don't take NET_LOCK to allow wg(4) to continue to send and
> - * receive packets while we're loading a large number of
> - * peers. wg(4) uses its own lock to serialise access. */
> error = ((*ifp->if_ioctl)(ifp, cmd, data));
> break;
>
> Index: net/if_wg.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_wg.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 if_wg.c
> --- net/if_wg.c 21 Jun 2020 12:11:26 -0000 1.3
> +++ net/if_wg.c 22 Jun 2020 09:06:37 -0000
> @@ -2450,10 +2450,14 @@ wg_ioctl(struct ifnet *ifp, u_long cmd,
>
> switch (cmd) {
> case SIOCSWG:
> + NET_UNLOCK();
> ret = wg_ioctl_set(sc, (struct wg_data_io *) data);
> + NET_LOCK();
> break;
> case SIOCGWG:
> + NET_UNLOCK();
> ret = wg_ioctl_get(sc, (struct wg_data_io *) data);
> + NET_LOCK();
> break;
> /* Interface IOCTLs */
> case SIOCSIFADDR:
>
Tested the patch: It fixes the problems i encountered.
Thank you!