From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796202250; b=Qo0RNLlIDxde/qjjNIXI/m42znxkIghBu12p+BjIe5fXPde2HtgfyiuhQ5I+uvNY/T9e VooIeR2MpgBEjpKNzCY/Yp5kxm/WvNaSGshVhOgJA8T1noLBaAsnVR2oH1g38wTzDBDPD vzfQ3/n4iL0gOBgsxpSsvawB9H50ZqRWH6BkxmJkJqpD0JaMNG/OjQuDXPKkm5DxqvJTR FRzOtoqQWAUEpjcInwvGOyGwuXxghAym6lbQM58HUF/IsTIVnDzFFb7HLZ9QXMmZu2dA4 p2+nI86aqsceFUeYrbraF3/yV1LsXDz6pU+FzvPktHFvr3U4bYVdtfK7XAgvesYCy0w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796202250; h=DMARC-Filter:Received:DKIM-Signature:DKIM-Signature:DKIM-Signature: DKIM-Signature:Received:Received:Date:Message-ID:From:To:Cc:Subject: In-Reply-To:References:User-Agent:MIME-Version:Content-Type: X-Spam-Flag:X-Spam-Level:X-Spamd-Result:X-Spam-Score; bh=geD0Y0i63VNBaPvAZHjZyKQFQhhCO4O1cbVuGb+5LY4=; b=Qnq58DWN5bu+b6LAXuJqrmA3BzJ1W0ur0hPNRq2IGQN3Qq67t0YPZTjwZ0J1qE34mFrE wDpObMf7vaEB4HsCIJb2xMZ4RQF5alqrTgEBEQI2tIEVwgTUQyID6J77dI/sdW25GDdJP jf9R666dO4+oHut/B6aN/JEDyxTn6oNSPZvgSyM1vHJHwnWXLSspZX1hKS264yiuLyYVV hJSS2PoJ7f8iaknctZQHCeGOZK6rwRIWoXSH3wyxsgp6CZnqoKuQv+eny5h8eNzY+QqtJ LwFhICkaaYRalrROfo35smo47VkGZjjaCNFFpyBVtvpEBkVeZkYOdh8N5pB+daQchGA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=IptXRAz4; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b="gO/D927N"; dkim=pass header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=SRjzWOHa; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=ZgiQ2GYf; arc=none smtp.remote-ip=195.135.223.131 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61880606A33F; Wed, 2 Dec 2026 09:04:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 61880606A33F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=IptXRAz4; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=gO/D927N; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=SRjzWOHa; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=ZgiQ2GYf Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6B62C1F79A; Wed, 2 Dec 2026 09:04:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1796202246; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=geD0Y0i63VNBaPvAZHjZyKQFQhhCO4O1cbVuGb+5LY4=; b=IptXRAz4uxffuljDNqgd/9DBlcWbLaT+fXL5vL1amzfS9GyruTfvHeSK6Na1VnPJbQR5JR E7ntMbxtcQRIUSfYu7+vOe+kFJ1wFviozNfHdkaZX3KJ8F4mcy/P8TeacJSM0dcF3tvFhZ +WyDG4o4qWzmi3EksKM2VGiT2Ev00jU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1796202246; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=geD0Y0i63VNBaPvAZHjZyKQFQhhCO4O1cbVuGb+5LY4=; b=gO/D927NZiPKBEH676GE3T0YKeJkOLRPcFStF6sITDBRVaW2bpcOz6fvOORsfXi2DUf3WK ZTAVDRKtj1eJ4RDQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1796202245; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=geD0Y0i63VNBaPvAZHjZyKQFQhhCO4O1cbVuGb+5LY4=; b=SRjzWOHatcaZIDofKj0B18vLAzsqWXKeuxEMMhjJoEcAaZINUXr6NONfsQynA7aba4CzbP FblJPdWhqRBG1ekdKFX79nJ7F9Xu89cO+7GId/eG13jcGHrAPaYas2Xw1azGRQYZQBzhIv Vc0SFPjviDYx0EqNP6HTBxvn0Irh2d4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1796202245; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=geD0Y0i63VNBaPvAZHjZyKQFQhhCO4O1cbVuGb+5LY4=; b=ZgiQ2GYfYrXM3Z+BY8hJajl5YrBXzpdvcEeR/k2ruaeeSZdTCD9HfTV97rS+enClcoUfhH iXLyVQC9TMKBWvCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 23CFB13505; Wed, 2 Dec 2026 09:04:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id YE1WOgTfD2vKEgAAD6G6ig (envelope-from ); Wed, 02 Dec 2026 09:04:05 +0000 Date: Wed, 02 Dec 2026 10:04:04 +0100 Message-ID: <87ecc0xddn.wl-tiwai@suse.de> From: Takashi Iwai To: Hanxiang Xu Cc: Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: emux: drain open hwdep users before freeing the emux structures In-Reply-To: <20261202101231.1-1-xuhx@hust.edu.cn> References: <20261202101231.1-1-xuhx@hust.edu.cn> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/30.2 Mule/6.0 X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Flag: NO X-Spam-Level: X-Spamd-Result: default: False [-12.30 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,hust.edu.cn:email] X-Spam-Score: -12.30 On Wed, 02 Dec 2026 03:12:31 +0100, Hanxiang Xu wrote: > > Opening a hwdep device of the emux wavetable pins only the base-card > module; the emux hwdep registers no open/release hooks, so an open fd > keeps file->private_data pointing at the struct snd_hwdep and in-flight > ioctls keep running against the emux structures while the sub-driver > removal (rmmod snd_emu10k1_synth, or unbind which bypasses module > refcounts) kfrees the hwdep, the soundfont list and the struct snd_emux > itself -- snd_hwdep_ioctl() holds no open_mutex and > snd_hwdep_dev_disconnect() neither checks hwdep->used nor revokes f_op > (dynamically confirmed on v7.4-rc5, 113 UAF reports). > > Register hwdep open/release hooks that account for the fd with > snd_emux_inc_count()/snd_emux_dec_count() -- which also pins the > sub-driver module like the sequencer and OSS-sequencer paths -- and > make snd_emux_free() wait until all hwdep users are gone before > tearing anything down, mirroring the drain snd_card_disconnect() > performs for whole-card removal. > > Cc: > Signed-off-by: Hanxiang Xu This could be replaced simply with a call of snd_card_file_sync(card, hwdep), instead? Also it can be covered similarly for vmidi rawmidi in emux code, too. Just add those before snd_device_free() calls. Takashi