From owner-freebsd-bugs@freebsd.org Tue Feb 12 20:56:47 2019 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C404914D0B4C for ; Tue, 12 Feb 2019 20:56:47 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 543FD821AF for ; Tue, 12 Feb 2019 20:56:47 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id 0F91614D0B4B; Tue, 12 Feb 2019 20:56:47 +0000 (UTC) Delivered-To: bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DC35414D0B4A for ; Tue, 12 Feb 2019 20:56:46 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 58435821AC for ; Tue, 12 Feb 2019 20:56:46 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id 958E2854E for ; Tue, 12 Feb 2019 20:56:45 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id x1CKujEh092165 for ; Tue, 12 Feb 2019 20:56:45 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id x1CKujva092164 for bugs@FreeBSD.org; Tue, 12 Feb 2019 20:56:45 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 235704] [net] [patch] tun(4) can't be destroyed on a VNET jail if it's renamed Date: Tue, 12 Feb 2019 20:56:45 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 12.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: genneko217@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Feb 2019 20:56:48 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D235704 Bug ID: 235704 Summary: [net] [patch] tun(4) can't be destroyed on a VNET jail if it's renamed Product: Base System Version: 12.0-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: genneko217@gmail.com Created attachment 201965 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D201965&action= =3Dedit diff to /usr/src If a tun(4) interface is created on a VNET jail and renamed to the name other than "tunX", the interface cannot be destroyed thereafter. If it is renamed back to "tunX", it becomes destroyable again. This issue only occurs on VNET jails and doesn't seem to happen on a host or a/non-VNET environment. How to Reproduce: 1. Boot a VIMAGE-enabled FreeBSD system. (I used 12.0-RELEASE-p3 with GENERIC kernel. See attached log.txt) 2. Create a VNET jail. 3. Create a tun(4) interface on the VNET jail, then rename it to the name other than "tunX". 4. Try to destroy the tun interface on the VNET jail. Expected Result: Step 4 removes the interface successfully. Actual Result: Step 4 fails with "SIOCIFDESTROY: Invalid argument". Minimal Set of Commands to Reproduce: (Assume the second command creates 'tun0') jail -c -n test vnet persist jexec test ifconfig tun create jexec test ifconfig tun0 name wg0 jexec test ifconfig wg0 destroy Workaround: The problem can be worked around by renaming the undestroyable tun interface to "tunX" (X can be any number which is not being used by other tun interfaces on the system). jexec test ifconfig wg0 name tun0 jexec test ifconfig tun0 destroy Possible Fix: See attached patch for if_clone_destroy() in sys/net/if_clone.c. I wrote and tested it on releng/12.0 and confirmed it solved this particular problem, but because of my lack of knowledge and experience (this is my first kernel debugging, report and patch submission ever) I'm not sure it's reasonable and doesn't break any other stuff. Background: I found this issue when I was experimenting with the WireGuard VPN (net/wireguard package) on VNET jails. On FreeBSD, WireGuard uses a userspace program (net/wireguard-go) to create its tunnel interface. The program first generates a tun interface by opening /dev/tun, then renames it to the one specified on the command line. When I used 'wg0' as the WireGuard interface name on a VNET jail, I noticed that it couldn't be destroyed as 'service wireguard stop' got stuck waiting the interface to be destroyed. Further investigation shows me that it's not specific to WireGuard. Thus I create this report. --=20 You are receiving this mail because: You are the assignee for the bug.=