Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796107059; b=M4vlHYLtW3h++VTJdC1nm7mLyRBJlU6JmGukb7h8/DkT+UV0BOW9/Ee80r1g8AObPyFz Kl7JmvlukywYnrzDzl6NFVX+qfINS9vLc6HFSky9vHIaIbKOK0f3gtdxIufb84Q+Oq4BZ p/z3BcsqCUairT+G0hdAkLqJjv81x7GE7CYY1khW5SHKxXs3mKDI1PV9RqqnsCddyBd8O TNQGCe7ZPYFC0mQMiwjsf8GomYo0fPWVvlz/qcP65dzHoS97bIyjrC8XBXsU/vnUAjCOF v/3vEcKl2Y1ExJGVGHAlJOwfGFGHbYZt0FZfNG8en6kEJ7eIDpHVnr/4fY50iqg5G9w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796107059; 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: Content-Transfer-Encoding:X-Spamd-Result:X-Rspamd-Server: X-Rspamd-Action:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Rspamd-Queue-Id; bh=iTsQHenos+qaowPF5LaZzHEP+NvNMDOZEoXT3NpR3cw=; b=X5+VFWtwlezmFSgolEKRc6bMjrYh0Zy44erBWF/gFeoAJB9EAsjc9VnqkJZgJvSgfzVS +jjZxFbA4/VNnieBpbLjcVc++FFJ6F3I6ygoZgSPT/9DxuZVFmeb43OWerVK+yN8TDRYk z3/1HzpXLoaPwRVZUWKrvfHgV5Xi/Je1wW0MBANTLae8cPsKlf/vopw9LUJXnY1XCkOSM k3oQwAaHf4Bbyp46tr3Uf0BXA519v8pxatBUm1dRgBqbLS44VWbfOhLjaRSpnK29kCcsQ OLbeOIHRl55GOGbKhPnMiOUpu+ZSl4eEgwrC/xm1aulxUn/IoNmds2Frry93WnP76rw== 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="YM/TSmxs"; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=4LmdxwwF; dkim=pass header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b="YM/TSmxs"; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=4LmdxwwF; arc=none smtp.remote-ip=195.135.223.130 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 EDFFD606A320; Tue, 1 Dec 2026 06:37:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EDFFD606A320 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=YM/TSmxs; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=4LmdxwwF; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=YM/TSmxs; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=4LmdxwwF Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out1.suse.de (Postfix) with ESMTPS id 2684C223BF; Tue, 1 Dec 2026 06:37:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1796107057; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iTsQHenos+qaowPF5LaZzHEP+NvNMDOZEoXT3NpR3cw=; b=YM/TSmxswT8A0FGpUGgzUkb4P0ukXcCQI5KPeoL21wvAxUA8D4xo7wOEGgY8GJort6u28q QZWLDFkVfeZMEuBBWQrTyy2AdlhfSMAU4CzHJPS44OJGv9/Hr7/nIrmvR4MAG94UWc2mJx H0gm02z4sOZ4HmHIA+q5qqGtfd31szI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1796107057; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iTsQHenos+qaowPF5LaZzHEP+NvNMDOZEoXT3NpR3cw=; b=4LmdxwwFpV7ZYzZ0oSKWZEr/AcLiqjC4qWnJm9HI2l55ui9aiqnFMJVQmHV6gaBFR/tdR9 JucGUqkmDS6WYFBg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="YM/TSmxs"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=4LmdxwwF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1796107057; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iTsQHenos+qaowPF5LaZzHEP+NvNMDOZEoXT3NpR3cw=; b=YM/TSmxswT8A0FGpUGgzUkb4P0ukXcCQI5KPeoL21wvAxUA8D4xo7wOEGgY8GJort6u28q QZWLDFkVfeZMEuBBWQrTyy2AdlhfSMAU4CzHJPS44OJGv9/Hr7/nIrmvR4MAG94UWc2mJx H0gm02z4sOZ4HmHIA+q5qqGtfd31szI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1796107057; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iTsQHenos+qaowPF5LaZzHEP+NvNMDOZEoXT3NpR3cw=; b=4LmdxwwFpV7ZYzZ0oSKWZEr/AcLiqjC4qWnJm9HI2l55ui9aiqnFMJVQmHV6gaBFR/tdR9 JucGUqkmDS6WYFBg== 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 DA56E134E9; Tue, 1 Dec 2026 06:37:36 +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 W6voLTBrDmseYgAAD6G6ig (envelope-from ); Tue, 01 Dec 2026 06:37:36 +0000 Date: Tue, 01 Dec 2026 07:37:36 +0100 Message-ID: <87mrqp1p73.wl-tiwai@suse.de> From: Takashi Iwai To: =?GB2312?B?0Ozqz8/o?= Cc: perex@perex.cz, tiwai@suse.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/2] ALSA: emux: fix use-after-free of soundfont zones/samples between snd_emux_note_on() and soundfont removal paths =?ISO-2022-JP?B?GyRCIUobKEJVQUYbJEIhSxsoQg==?= In-Reply-To: References: <4c7f9772.192e1.1a17d5c2ed5.Coremail.xuhx@hust.edu.cn> <2026102727-data-sequel-ce41@gregkh> 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=GB2312 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-12.51 / 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]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -12.51 X-Spam-Level: X-Rspamd-Queue-Id: 2684C223BF On Tue, 01 Dec 2026 04:22:23 +0100, ذٌيددو wrote: > > snd_emux_note_on() obtains raw struct snd_sf_zone pointers from > snd_soundfont_search_zone(), which drops sflist->lock on return, and > then consumes them (exclusive-class read, sample/block chaining, a > 92-byte register copy) with no lock, no reference count and no RCU > protection, while four user-reachable soundfont removal paths > (hwdep SNDRV_EMUX_IOCTL_REMOVE_LAST_SAMPLES / RESET_SAMPLES / > LOAD_PATCH(REMOVE_INFO) and OSS SNDCTL_SEQ_RESETSAMPLES) kfree() the > very same zones, samples and util-mem blocks under a disjoint mutex. > The two sides share no lock domain (presets_mutex vs voice_lock), and > the emu10k1 backend additionally keeps already-playing voices pointed > at freed blocks because emu10k1_ops has no .sample_reset callback. > > Verified on mainline 7.3 with a KASAN kernel and the real in-tree > snd-emux-synth module driven through its exported API (harness > attached): an uninstrumented natural hammer (userspace soundfont > load/unload loop through the real hwdep ioctl path vs kernel note_on > loop) produced 133 slab-use-after-free reports in 25s across four > distinct read points inside snd_emux_note_on(), with a closed > alloc/free/use chain (alloc = sf_zone_new <- load_info <- > snd_soundfont_load <- snd_emux_hwdep_ioctl <- real userspace ioctl; > free = kfree <- snd_soundfont_remove_unlocked; use = snd_emux_note_on > +0x225/0x75f/0x772/0x7ab). A controlled one-shot that parks note_on > inside its window reproduces deterministically (6 reports). The > in-flight window needs no privileges beyond access to the sound > devices; consequences are kernel memory corruption (UAF reads plus a > UAF write through the block pointer) and crashes. > > The detailed description: > > * Test environment / affected version > > Linux version 7.3.0 (gcc 13.3.0, GNU ld 2.42) #6 SMP > PREEMPT_DYNAMIC -- vanilla mainline 7.3 tree, unmodified sources; > KASAN enabled, QEMU/KVM x86_64 guest. The audited files > (sound/synth/emux/*, sound/synth/util_mem.c, > sound/pci/emu10k1/emu10k1_callback.c) are byte-identical between the > tested tree and the report baseline. The bug predates 7.3 by many > years (the emux split-probe model and the unlocked search are > essentially unchanged since the 2.6 emux import); line numbers below > are from 7.3. 7.3.0 is way too old for this kind of bug hunts via AI. Could you verify the whole series (and your other patches) at least with 7.4-rc5? At best with the latest linux-next tree, as some fixes are postponed to 7.5. This may save a waste of time for both of us. thanks, Takashi