Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31963ECAAD3 for ; Wed, 7 Sep 2022 06:00:27 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1122A1E8; Wed, 7 Sep 2022 07:59:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1122A1E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1662530426; bh=YcDGj/qBZnxCNSPN9jBNGdS0cyjYkMVS6RXX+0GvU9I=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lgnSntzzEGa7NXiVsKyX0w0lYCnuUebd9AgNHkZ/sg+x5n7uJMsM3FHq2O70QWDHY +wwscnsboKL44SnHbD1OqFcROXqKv8FluwZ5OQXcoTM/nX95OtvE/EMU4iu57H4zN0 nTKSP+BSUfFeX2ERiGeQt4XqWpumMaDq6SVt0J2A= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AC826F80249; Wed, 7 Sep 2022 07:59:35 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0F9D2F8028D; Wed, 7 Sep 2022 07:59:35 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BD278F80118 for ; Wed, 7 Sep 2022 07:59:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BD278F80118 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="hXYRX5Wl"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="7v8PjGIU" Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E2B2820002; Wed, 7 Sep 2022 05:59:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662530367; 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=cwcjiuBkUe/FtJKT7lUDznO/qVB6v18xiw7jWQvWmZU=; b=hXYRX5WlTJ6/RejL4MGt7NSijaMuDjE92Q+NPOl9SczsUA0SaJlbgkhlM8CJgm0FRNPHg8 eMQjnJB4s+I0daq4RRueN3cRumL0EMd9yy7QClvCR6pxrCzwcbzpjLEG0MVI/go1lsyOik pBfzNG2IvPRk69+zOrq4eIOcUDhkx5k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662530367; 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=cwcjiuBkUe/FtJKT7lUDznO/qVB6v18xiw7jWQvWmZU=; b=7v8PjGIU+GRF8l9P4Vu7yKj+PE7QtnFl2dKpgSSu2hHW8uwhlxs/9K2ZJYfedM9WFpfdom bGw+yaie3Zx5UABQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C474913A66; Wed, 7 Sep 2022 05:59:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yTgvLz8zGGMzVgAAMHmgww (envelope-from ); Wed, 07 Sep 2022 05:59:27 +0000 Date: Wed, 07 Sep 2022 07:59:26 +0200 Message-ID: <87pmg7encx.wl-tiwai@suse.de> From: Takashi Iwai To: Tasos Sahanidis Subject: Re: [PATCH] ALSA: emu10k1: Fix out of bounds access in snd_emu10k1_pcm_channel_alloc() In-Reply-To: <3707dcab-320a-62ff-63c0-73fc201ef756@tasossah.com> References: <3707dcab-320a-62ff-63c0-73fc201ef756@tasossah.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Cc: alsa-devel@alsa-project.org, tiwai@suse.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Wed, 07 Sep 2022 03:18:00 +0200, Tasos Sahanidis wrote: > > The voice allocator sometimes begins allocating from near the end of the > array and then wraps around, however snd_emu10k1_pcm_channel_alloc() > accesses the newly allocated voices as if it never wrapped around. > > This results in out of bounds access if the first voice has a high enough > index so that first_voice + requested_voice_count > NUM_G (64). > The more voices are requested, the more likely it is for this to occur. > > This was initially discovered using PipeWire, however it can be reproduced > by calling aplay multiple times with 16 channels: > aplay -r 48000 -D plughw:CARD=Live,DEV=3 -c 16 /dev/zero > > UBSAN: array-index-out-of-bounds in sound/pci/emu10k1/emupcm.c:127:40 > index 65 is out of range for type 'snd_emu10k1_voice [64]' > CPU: 1 PID: 31977 Comm: aplay Tainted: G W IOE 6.0.0-rc2-emu10k1+ #7 > Hardware name: ASUSTEK COMPUTER INC P5W DH Deluxe/P5W DH Deluxe, BIOS 3002 07/22/2010 > Call Trace: > > dump_stack_lvl+0x49/0x63 > dump_stack+0x10/0x16 > ubsan_epilogue+0x9/0x3f > __ubsan_handle_out_of_bounds.cold+0x44/0x49 > snd_emu10k1_playback_hw_params+0x3bc/0x420 [snd_emu10k1] > snd_pcm_hw_params+0x29f/0x600 [snd_pcm] > snd_pcm_common_ioctl+0x188/0x1410 [snd_pcm] > ? exit_to_user_mode_prepare+0x35/0x170 > ? do_syscall_64+0x69/0x90 > ? syscall_exit_to_user_mode+0x26/0x50 > ? do_syscall_64+0x69/0x90 > ? exit_to_user_mode_prepare+0x35/0x170 > snd_pcm_ioctl+0x27/0x40 [snd_pcm] > __x64_sys_ioctl+0x95/0xd0 > do_syscall_64+0x5c/0x90 > ? do_syscall_64+0x69/0x90 > ? do_syscall_64+0x69/0x90 > entry_SYSCALL_64_after_hwframe+0x63/0xcd > > Signed-off-by: Tasos Sahanidis Oh it's an old bug... Now applied. Thanks! Takashi