From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2011C00140 for ; Wed, 24 Aug 2022 09:42:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235798AbiHXJma (ORCPT ); Wed, 24 Aug 2022 05:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229884AbiHXJm2 (ORCPT ); Wed, 24 Aug 2022 05:42:28 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5592E3A4B1 for ; Wed, 24 Aug 2022 02:42:27 -0700 (PDT) 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 D5A9C202C6; Wed, 24 Aug 2022 09:42:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1661334145; 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=k9tdDx4tevBZYu34e0FF1R86AaQXWWnuGILrZlABPYM=; b=c4eX8iwj8ypAzqBbhKzQKGdr8e015OslV4uHMG9Pk6kAOZ8HsHjcDO4gLgIlty73r6DCnz fBUbMl7K0BK4+bYMD9Bi+d06O6ay/aN2zmPIQ8m8AbEZe+y2fqJHouR/WP9rYVFCx2xOAz yaEuyLHp8ibeGaID4Eun2ireQhVL9nU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1661334145; 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=k9tdDx4tevBZYu34e0FF1R86AaQXWWnuGILrZlABPYM=; b=2buHS59whnuzB1XJFK0qUyOj8cXsoShBx1M1LXR1oVtf8qiQDKT4BxJIMlgEA4UcFsg4KS CJRiHNg2pzdjmrBw== 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 B210B13AC0; Wed, 24 Aug 2022 09:42:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 52zsKoHyBWMkCAAAMHmgww (envelope-from ); Wed, 24 Aug 2022 09:42:25 +0000 Date: Wed, 24 Aug 2022 11:42:25 +0200 Message-ID: <87ilmirn9a.wl-tiwai@suse.de> From: Takashi Iwai To: Zheyu Ma Cc: Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: control: Fix an out-of-bounds bug in get_ctl_id_hash() In-Reply-To: <20220824081654.3767739-1-zheyuma97@gmail.com> References: <20220824081654.3767739-1-zheyuma97@gmail.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 24 Aug 2022 10:16:54 +0200, Zheyu Ma wrote: > > Since the user can control the arguments provided to the kernel by the > ioctl() system call, an out-of-bounds bug occurs when the 'id->name' > provided by the user does not end with '\0'. > > The following log can reveal it: > > [ 10.002313] BUG: KASAN: stack-out-of-bounds in snd_ctl_find_id+0x36c/0x3a0 > [ 10.002895] Read of size 1 at addr ffff888109f5fe28 by task snd/439 > [ 10.004934] Call Trace: > [ 10.007140] snd_ctl_find_id+0x36c/0x3a0 > [ 10.007489] snd_ctl_ioctl+0x6cf/0x10e0 > > Fix this by checking the bound of 'id->name' in the loop. > > Fixes: c27e1efb61c5 ("ALSA: control: Use xarray for faster lookups") > Signed-off-by: Zheyu Ma Thanks, applied now. Takashi