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=1796201567; b=a2SCdWDkLtucEaXMvZIhwAM8rqmqHReNQ7dERpo3NxqgT3MqEtR6F6EIyUGvuD/qOmL4 Z96xNu6lBi3yHXF4NvstJi24Sz2HUvQBQfxdEPHPp3bfTCNFX6dRMUtvoF0v3UCv0AUo5 vERAU7sHPmWVEolnOL/kNpJphOCJxOVV3MCbdLEe7wdCfegneAoat/b4SyoV9DmWXWeuw CnVQteagjfZxJdLJQON2F8IikO8ap/UJt0gdVd8MRMnXcUiAsVpdQgPkk8fG1OJJxr/Z7 n5a3UUH5crdnMMIDNMBGUiBpUXFMwWxlDVCR4y7W9+LwJzqi6h4u8b8EM6z+uj2W9gQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796201567; h=DMARC-Filter:Received:Received:Received:Date:Message-ID:From:To:Cc: Subject:In-Reply-To:References:User-Agent:MIME-Version:Content-Type: X-Rspamd-Pre-Result:X-Rspamd-Server:X-Spamd-Result:X-Spam-Flag: X-Spam-Score:X-Spam-Level:X-Rspamd-Queue-Id:X-Rspamd-Pre-Result: X-Rspamd-Action; bh=1Al4/IqG1fp8PRP7UW/LBa65MQsEj/JS0fpi/w+xsC0=; b=IkG7IZdxON5rjF+/h+FyMVWktAy1UcNUvB9e6Dk18mOhxeKd6cIPWladInZUc/8IltV7 +UuQj4HAtzhSH/ydV3HRYZet/yC25R7mljLDWaPDshhgIt3V1sylK2vsYtHbHbgADR0EZ YWTdauI7270pf/tY4MeTrqAS2/9phikjcFMKVjrmKXRvaTpNEVBWqrwrOlTAuuau8dp6l Xk8tv2a3sgTG3KkLfEoCis6VNk+VXuLlEJ9WIxG0oFlVcSXvI7KsqEb3Q7UAL0TYZcYj0 WKUzIzUSOePFjoo2Iu53W8ILwxqoHxk9Hdz3xnM6K/dAg6IXVnkzb2A0eqFeo8qKEGA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=suse.de; spf=pass smtp.mailfrom=suse.de; 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 26670606A692; Wed, 2 Dec 2026 08:52:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 26670606A692 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 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-out2.suse.de (Postfix) with ESMTPS id 608DF1FB13; Wed, 2 Dec 2026 08:52:45 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none 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 0408913505; Wed, 2 Dec 2026 08:52:44 +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 r/L4MlzcD2tbBwAAD6G6ig (envelope-from ); Wed, 02 Dec 2026 08:52:44 +0000 Date: Wed, 02 Dec 2026 09:52:44 +0100 Message-ID: <87ld68xdwj.wl-tiwai@suse.de> From: Takashi Iwai To: Takashi Iwai Cc: Hanxiang Xu , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: emu8000: sync the PCM emulation timer before freeing snd_emu8k_pcm (uaf from the in-flight softirq callback) In-Reply-To: <87mrqoxe3x.wl-tiwai@suse.de> References: <20261202022039.1-1-xuhx@hust.edu.cn> <87mrqoxe3x.wl-tiwai@suse.de> 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-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: X-Rspamd-Queue-Id: 608DF1FB13 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action On Wed, 02 Dec 2026 09:48:18 +0100, Takashi Iwai wrote: > > On Tue, 01 Dec 2026 19:20:39 +0100, > Hanxiang Xu wrote: > > > > The emu8000 PCM emulation drives its period handling from a timer > > that re-arms itself every jiffie (emu8k_pcm_timer_func() -> > > mod_timer() inside the rec->timer_lock section). Stopping the stream > > uses the non-synchronizing timer_delete() (stop_voice()), which > > cannot affect a callback instance that is already executing in > > softirq context, and emu8k_pcm_close() then kfree()s rec with no > > timer_delete_sync() and nothing stops a running instance from > > re-arming. An in-flight emu8k_pcm_timer_func() therefore continues > > on freed memory: it dereferences rec->emu, locks the freed > > rec->timer_lock, writes rec->period_pos, re-arms the freed timer (a > > ghost timer firing every tick), and reads rec->substream for > > snd_pcm_period_elapsed(). stop_voice() runs under the stream > > spinlock, so the sync cannot be added there - but close() is process > > context. > > > > Gate the re-arm on rec->timer_running (under the rec->timer_lock that > > stop_voice() already clears) and wait for an in-flight callback with > > timer_delete_sync() before kfree(rec) in emu8k_pcm_close(). > > > > Cc: > > Signed-off-by: Hanxiang Xu > > Applied to for-next branch. Thanks. .... then I noticed that you've submitted another conflicting patch for this driver. So I have to drop this one again. *PLEASE* don't submit patches in this style. Group a patch series and use a thread if you submit a bunch of patches. Takashi