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=1796226435; b=oc6cO2gZ5RiuqWS7IN2n7GK0CXqgfqNVzEuFRPH42IMRcUhZMbH0cXxjzLl/oZ8HLz5W Ck455T1FYOnzXuiuZSQFDCCkIoB+XoWssVLlZKpX6AffyLWEatKbX6FsFni58Oq3JYoAS EVEfEIvo/XlfQ3/bh+y2YPFQrDVPwKVYYo4GwgLfrVKkfY84Pv9RVYjxcXQg/qIp42J+H m7ByAnyTQyLghp669Cylx97+gMQvtYcypWCrGCT8WyXTlraEaepu4tBJoqLeRG8/iBjr1 slQdRPz2AJGRznZ0oyuGIfpMPoK37Zod1xgAYrE8A6pZ/K9UOE3iRiTbdUGE4Ej6Xcw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796226435; 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-Spamd-Result:X-Rspamd-Server:X-Rspamd-Action:X-Spam-Flag: X-Spam-Score:X-Spam-Level:X-Rspamd-Queue-Id; bh=vlEupJA93GoJ5fpWT40jLYphqcKzZgesQW2pL1H/Au8=; b=lkmp1YLdfMn5ySQ7tMZlhr/stKzSgq9cPz2fUVmpDcQgm3RbgknnAKUeZU+LUzO2k8+h 68h2nFA85iVtn+oBTLlLilhFiBTEgUnl4vS5vIj09Y2dOF3wz3Tw3i1fp5gkEoUKxKxJP yeT203OQERQiRMUlTB6kyvXzoVAn+53o5wPyLvJOOvU/Lv/GsVrAfM2mRHz2Yz4E+0Ol4 HtVv8tPDT/Od6XSurPEaNfvbLg6vNyITYTphDPPhikf405wUQdU/xTgOBmQzhv/fiF4Kr yis9Bn8EODQfS5wPyIqTodEDVlxct4lO1eHIfCGFiZ5TwaZdsIb1ktR5cMN5+btPO9g== 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=iGwRWgsP; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5NvDWPPO; dkim=pass header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=iGwRWgsP; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5NvDWPPO; 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 D7A5B606A31A; Wed, 2 Dec 2026 15:47:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D7A5B606A31A 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=iGwRWgsP; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5NvDWPPO; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=iGwRWgsP; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5NvDWPPO 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 AE9C920274; Wed, 2 Dec 2026 15:47:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1796226432; 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=vlEupJA93GoJ5fpWT40jLYphqcKzZgesQW2pL1H/Au8=; b=iGwRWgsPZut7le+scwRXBEkvTp9Lfz9NhmLvyrxRbW64Ay7pHt0JxZGqFSK0RDmi+w62Fp Hd8LS4q0bLZVOzedZE5aDdyOdcbhn8woRfnm/0wAc+3497y30cdLkpio0eQL7txbPWdPXM /NrCn5hPOZmBEnqCNWa2yFNA+4vUg0A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1796226432; 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=vlEupJA93GoJ5fpWT40jLYphqcKzZgesQW2pL1H/Au8=; b=5NvDWPPOyovDVAL/J1ptBHTvbmbT5Uyn3ItYc6rJjlUA2ZcqYMMKMRHQ7a8ljuhJJsCHqA Gh30OfdcaSVBxvBg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=iGwRWgsP; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=5NvDWPPO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1796226432; 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=vlEupJA93GoJ5fpWT40jLYphqcKzZgesQW2pL1H/Au8=; b=iGwRWgsPZut7le+scwRXBEkvTp9Lfz9NhmLvyrxRbW64Ay7pHt0JxZGqFSK0RDmi+w62Fp Hd8LS4q0bLZVOzedZE5aDdyOdcbhn8woRfnm/0wAc+3497y30cdLkpio0eQL7txbPWdPXM /NrCn5hPOZmBEnqCNWa2yFNA+4vUg0A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1796226432; 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=vlEupJA93GoJ5fpWT40jLYphqcKzZgesQW2pL1H/Au8=; b=5NvDWPPOyovDVAL/J1ptBHTvbmbT5Uyn3ItYc6rJjlUA2ZcqYMMKMRHQ7a8ljuhJJsCHqA Gh30OfdcaSVBxvBg== 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 6311A1348F; Wed, 2 Dec 2026 15:47:12 +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 xlzQDoA9EGtPNAAAD6G6ig (envelope-from ); Wed, 02 Dec 2026 15:47:12 +0000 Date: Wed, 02 Dec 2026 16:47:11 +0100 Message-ID: <87jylrwups.wl-tiwai@suse.de> From: Takashi Iwai To: Ahmed Abdelmoemen Cc: tiwai@suse.com, perex@perex.cz, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/3] ALSA: pcm: Fix OSS mmap buffer-lifetime issues In-Reply-To: <20261202140117.1164633-1-ahmedabdelmoumen05@gmail.com> References: <20261202140117.1164633-1-ahmedabdelmoumen05@gmail.com> 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-Spamd-Result: default: False [-12.51 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; 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)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+] 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: AE9C920274 On Wed, 02 Dec 2026 15:01:14 +0100, Ahmed Abdelmoemen wrote: > > These three patches fix memory-safety issues in the ALSA PCM OSS > compatibility path (sound/core/pcm_native.c, CONFIG_SND_PCM_OSS=y). > I reported them earlier; as Greg noted that went to a public list, so > here are the patches. > > Common root cause: the DMA buffer is mapped to userspace with > remap_pfn_range() (VM_PFNMAP), which carries no page refcount. The > kernel therefore cannot revoke the mapping when the buffer is cleared, > reallocated, or freed. Each patch removes one way to reach that state. > > Patch 1 - hw_params_state_check() skips the mmap_count guard for OSS > streams via is_oss_stream(). That lets hw_params reconfigure (clear or > reallocate) the buffer while userspace still holds a live mapping. > Removing the exception makes the guard apply to all stream types. > > Patch 2 - the hw_params error path frees a managed buffer without > checking mmap_count. With preallocate_dma=0 the pages go back to the > allocator while a VM_PFNMAP mapping may still reference them - a > use-after-free. The free is guarded directly, so it holds even > independent of patch 1. > > Patch 3 - snd_pcm_mmap_data() allows mapping PAGE_ALIGN(dma_bytes); when > the logical buffer is sub-page (e.g. 512 bytes via OSS SETFRAGMENT) the > page tail can be exposed with stale contents. The tail is now zeroed > before the mapping is established. > > Reproduction: on an unprivileged /dev/dsp with preallocate_dma=0, a > mapping that outlives the buffer free (patches 1+2) can be used to read > and write pages after they are reallocated to other kernel objects. PoC > and a QEMU harness (x86-64, intel8x0/AC97, kernel 6.8.12): > > https://github.com/bohmiiidd/linux-UAF > > The code paths are present in current mainline. Built and checkpatch- > clean against 7.4.0-rc with CONFIG_SND_PCM_OSS=m. > > Feedback welcome - happy to respin. > > Ahmed Abdelmoemen (3): > ALSA: pcm: Remove is_oss_stream() bypass of mmap_count check > ALSA: pcm: Check mmap_count before freeing buffer in error path > ALSA: pcm: Clear mmap tail padding to avoid info leak I had the same fix for the first patch (disallowing OSS mmap), and cooked a more fix series without submission. Since this series seems still requiring more fixes, I'll revisit mine and try submitting. thanks, Takashi