From nobody Thu Jun 18 19:33:42 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gh9rQ5SZDz6hpK7 for ; Thu, 18 Jun 2026 19:33:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gh9rQ4B6Jz3mV4 for ; Thu, 18 Jun 2026 19:33:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781811222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=V2H4OxmuipVX095EcZuEfVWLt7v+VodkSPa7f35Y8Gc=; b=KHxSasxQ8YBKSaiEUr/fGGIXtxb3azMPEyrqe7b2qtkYmMeTh4NTD63hK3LcTkLV+RMOfM lCCU5eM6vJSek3X5BFz1KRTrhGis5HJcSkEqzfj4Wo8fbGjXwsKUNY/fakmpfr3eLrQR3Y wj+wmJcSD6N6uOMtmnTXTGu4o9D6EroTsRJm8PcAGjMdvYbgXe3MQbxZ0iiW2gqFDvT0QV 9cD0yYjOER0+NFu8XPeWVFxNfDH4bztdnfR2SgMwmxKAyCUDMPVUbnqI1Nsk3ZXkvRlsW5 04691WH3SHa7z62VkAobusRqO9Rucd8qDMMLaR211IPxioQcKuvc1LjRkMDrlg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781811222; a=rsa-sha256; cv=none; b=VKBNmX4XRBAgUItPjZQEFLwlA2AofKYEcqmMLWAKxytvNMoZG+L1OBHNQPBVrnkD8l/aZZ KQR/KM3P50eVD7vIpwB+yX3O+avQ2VfHV41fewm9DL9hGFzLwrCZCYji/n6w7DLU2lf5Q4 VsySb/y3dcU2v/8415/nHoWluMBAhU3AYEU2AkuUn9Vg8XoytvmhjKT8yT4uh43Irr/5Hl uK2EVKgzs6dyV9F8nSt8LukeAFRxsJY7yczsc0xoQumycpBDdbpgrbFKTe1hrlRhk4E3fN 2Mwx3IqSHomJ53DKQTROHyuEw8F+nMxfW0C9YS3ZOhOQGwqYg6dz2JFh0hU1yA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781811222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=V2H4OxmuipVX095EcZuEfVWLt7v+VodkSPa7f35Y8Gc=; b=JLLEOroTn6SEMmGjLYgwoBqn4v3Ls3S9a4KBavvzAhtr/u4h08/HBA/16GPXS/d1YrToTg VVCIngs6iDbzib3OxxVPG6kP0rNEO3H27jFWZc7bJYUS3L1gWPh791rxvD0ynR6ylly07B Fg8zryv6FgStGb+/OT4d3hpa6z4PwxfCm+0w6iSvZfr86TcTYv+Cgqdqvddjk5mq8zWwhJ jIOuijkTc9kXBwuP5QfkuzFvesMt2mSah7zOQAdjbb1mkcK+fZrgjZfkUQm/vBM6ZzqjM7 fJa/GlAuHlZRjvbrSUpykCYbzdeW2SCYpDIbZ7nRzrnKMoszqznblq5gvvRWVA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gh9rQ33Pxz1Blj for ; Thu, 18 Jun 2026 19:33:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 34669 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 18 Jun 2026 19:33:42 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: 013af29c1e17 - stable/15 - virtual_oss(8): Properly cleanup cuse(3) List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 013af29c1e1727ae4c8cae8167d4ad55a1c1d778 Auto-Submitted: auto-generated Date: Thu, 18 Jun 2026 19:33:42 +0000 Message-Id: <6a344816.34669.5c94d25e@gitrepo.freebsd.org> The branch stable/15 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=013af29c1e1727ae4c8cae8167d4ad55a1c1d778 commit 013af29c1e1727ae4c8cae8167d4ad55a1c1d778 Author: Christos Margiolis AuthorDate: 2026-05-29 11:32:42 +0000 Commit: Christos Margiolis CommitDate: 2026-06-18 19:33:35 +0000 virtual_oss(8): Properly cleanup cuse(3) virtual_oss(8) does not currently keep track of the cuse(3) it creates, nor does it destroy any of them on exit, except for the control device. This is harmless if virtual_oss(8) is killed after all audio streams have been shut down, but if it's killed during I/O, the process hangs and/or goes into uninterruptible sleep state. To fix this, have pointers to all cuse(3) devices, and explicitly destroy them on exit. Also make sure we don't leak memory in dup_profile(). Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: jrm Pull-Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/41 (cherry picked from commit 0bd5ef6b43633a3cf77495a087a9376b2b3b11c9) --- usr.sbin/virtual_oss/virtual_oss/int.h | 2 ++ usr.sbin/virtual_oss/virtual_oss/main.c | 39 +++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/usr.sbin/virtual_oss/virtual_oss/int.h b/usr.sbin/virtual_oss/virtual_oss/int.h index 69a943832074..dbe35dbefd58 100644 --- a/usr.sbin/virtual_oss/virtual_oss/int.h +++ b/usr.sbin/virtual_oss/virtual_oss/int.h @@ -120,6 +120,8 @@ struct virtual_profile { vclient_head_t head; char oss_name[VMAX_STRING]; char wav_name[VMAX_STRING]; + struct cuse_dev *oss_dev; + struct cuse_dev *wav_dev; uint32_t rx_filter_size; uint32_t tx_filter_size; double *rx_filter_data[VMAX_CHAN]; diff --git a/usr.sbin/virtual_oss/virtual_oss/main.c b/usr.sbin/virtual_oss/virtual_oss/main.c index b66d17d940af..a6cf691e7fbb 100644 --- a/usr.sbin/virtual_oss/virtual_oss/main.c +++ b/usr.sbin/virtual_oss/virtual_oss/main.c @@ -1856,6 +1856,15 @@ done: nvlist_destroy(nvl); } +static void +cleanup_profile(vprofile_t *pvp) +{ + if (pvp->oss_dev != NULL) + cuse_dev_destroy(pvp->oss_dev); + if (pvp->wav_dev != NULL) + cuse_dev_destroy(pvp->wav_dev); +} + static const char * dup_profile(vprofile_t *pvp, int *pamp, int pol, int rx_mute, int tx_mute, int synchronized, int is_client) @@ -1863,6 +1872,7 @@ dup_profile(vprofile_t *pvp, int *pamp, int pol, int rx_mute, vprofile_t *ptr; struct cuse_dev *pdev; struct group *gr; + const char *errstr; gid_t gid; int x, perm; @@ -1935,9 +1945,10 @@ dup_profile(vprofile_t *pvp, int *pamp, int pol, int rx_mute, pdev = cuse_dev_create(&vclient_oss_methods, ptr, NULL, 0, gid, perm, ptr->oss_name); if (pdev == NULL) { - free(ptr); - return ("Could not create CUSE DSP device"); + errstr = "Could not create CUSE DSP device"; + goto err; } + ptr->oss_dev = pdev; /* register to sndstat */ ptr->fd_sta = open("/dev/sndstat", O_WRONLY); @@ -1952,9 +1963,10 @@ dup_profile(vprofile_t *pvp, int *pamp, int pol, int rx_mute, pdev = cuse_dev_create(&vclient_wav_methods, ptr, NULL, 0, gid, perm, ptr->wav_name); if (pdev == NULL) { - free(ptr); - return ("Could not create CUSE WAV device"); + errstr = "Could not create CUSE WAV device"; + goto err; } + ptr->wav_dev = pdev; } atomic_lock(); @@ -1989,6 +2001,13 @@ dup_profile(vprofile_t *pvp, int *pamp, int pol, int rx_mute, init_compressor(pvp); return (voss_httpd_start(ptr)); + +err: + cleanup_profile(ptr); + free(ptr); + + return (errstr); + } static void @@ -2558,6 +2577,7 @@ main(int argc, char **argv) const char *ptrerr; struct sigaction sa; struct cuse_dev *pdev = NULL; + struct virtual_profile *pvp; TAILQ_INIT(&virtual_profile_client_head); TAILQ_INIT(&virtual_profile_loopback_head); @@ -2643,8 +2663,19 @@ main(int argc, char **argv) destroy_threads(); + /* Destroy CUSE devices */ + if (voss_ctl_device[0] != 0) cuse_dev_destroy(pdev); + TAILQ_FOREACH(pvp, &virtual_profile_client_head, entry) { + cleanup_profile(pvp); + } + TAILQ_FOREACH(pvp, &virtual_profile_loopback_head, entry) { + cleanup_profile(pvp); + } + + cuse_uninit(); + return (0); }