NetBSD Problem Report #58024

From www@netbsd.org  Sun Mar 10 04:40:01 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id AC5D11A923C
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 10 Mar 2024 04:40:01 +0000 (UTC)
Message-Id: <20240310044000.1D3791A923F@mollari.NetBSD.org>
Date: Sun, 10 Mar 2024 04:40:00 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: wg-userspace N destroy fails to destroy tun interface created by wg-userspace N create
X-Send-Pr-Version: www-1.0

>Number:         58024
>Category:       bin
>Synopsis:       wg-userspace N destroy fails to destroy tun interface created by wg-userspace N create
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 10 04:45:01 +0000 2024
>Last-Modified:  Sun Mar 10 10:10:01 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, 10
>Organization:
The WgBSD Userspace
>Environment:
>Description:
`wg-userspace 0 create' creates an interface tun0, but `wg-userspace 0 destroy' leaves it around without destroying it.
>How-To-Repeat:
wg-userspace 0 create
wg-userspace 0 destroy
>Fix:
Yes, please!

>Audit-Trail:
From: Taylor R Campbell <riastradh@NetBSD.org>
To: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Cc: 
Subject: Re: bin/58024: wg-userspace N destroy fails to destroy tun interface created by wg-userspace N create
Date: Sun, 10 Mar 2024 06:46:03 +0000

 The EEXIST happens because of all this crud in the opencrypto rump
 component, used to create the /dev/crypto node in the rump system's
 namespace:

 https://nxr.netbsd.org/xref/src/sys/rump/dev/lib/libopencrypto/opencrypto_c=
 omponent.c?r=3D1.6#54

      54 	if ((error =3D devsw_attach("crypto", NULL, &bmaj,
      55 	    &crypto_cdevsw, &cmaj)) !=3D 0)
      56 		panic("cannot attach crypto: %d", error);
      57=20
      58 	if ((error =3D rump_vfs_makeonedevnode(S_IFCHR, "/dev/crypto",
      59 	    cmaj, 0)) !=3D 0)
      60 		panic("cannot create /dev/crypto: %d", error);
      61=20
      62 	/*
      63 	 * Initialize OpenCrypto and its pseudo-devices here
      64 	 */
      65 	crypto_init();
      66 	rump_pdev_add(cryptoattach, 1);
      67 #if 0
      68 	/*
      69 	 * rump defines "_MODULE" in spite of using built-in module
      70 	 * initialization(module_init_class()). So, swcryptoattach_interna=
 l()
      71 	 * is called by two functions, one is swcryptoattach() and the oth=
 er is
      72 	 * swcrypto_modcmd().
      73 	 * That causes "builtin module `swcrypto' failed to init" WARNING =
 message.
      74 	 * To suppress this warning, we let rump use swcrypto_modcmd() cal=
 l-path
      75 	 * only.
      76 	 *
      77 	 * TODO:
      78 	 * There is still "crypto: unable to register devsw, error 17" mes=
 sage.
      79 	 * it should be suppressed.
      80 	 */
      81 	rump_pdev_add(swcryptoattach, 0);
      82 #endif

 This is all very grody and should be done differently, and it's not
 clear that just suppressing the warning here is right.

From: matthew green <mrg@eterna23.net>
To: Taylor R Campbell <riastradh@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: re: bin/58024: wg-userspace N destroy fails to destroy tun interface created by wg-userspace N create
Date: Sun, 10 Mar 2024 21:04:59 +1100

 Taylor R Campbell writes:
 > The EEXIST happens because of all this crud in the opencrypto rump

 the reason i said this is that the problem exists in a bunch of
 other places as.  i see it for various *verbose modules, for some
 vfs ones.. if each instance needs work perhaps, but it also seems
 to me that if the code can just eat EEXIST here, a bunch of code
 to check if module or already loaded or whatever could just be a
 single call to a new function, that succeeds if builtin or the
 module is already loaded, could be removed in each place.


 .mrg.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.