Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp397156rwe; Wed, 24 Aug 2022 02:59:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR5MKr8MVgRzdeUBNbXFRwhXvDopPu7X5h0Hclxqx3HdEcw7mjiXwff7+ZNz4dK75mMOxpLy X-Received: by 2002:a63:f753:0:b0:42a:bfc9:ea52 with SMTP id f19-20020a63f753000000b0042abfc9ea52mr10567986pgk.408.1661335199470; Wed, 24 Aug 2022 02:59:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661335199; cv=none; d=google.com; s=arc-20160816; b=jez92AOKGwfLaDNxHbdQsitcLS33tYuJT+7EoT1oMXqWgeRoyd699tXVDGGWDCAyRb VEsFWlOvpVSjpUoV3egfvLvgHf00ozoXEYz/vZNd0ZzXgRRDzLCy+TGpb0xytbjsHSq1 PlJ5O4o5WiNw7a4Pkuzpos/iBG+YO2Fb6+PJutCkualjwnPj+mLs2A4s9JmSdlGkZgKS NABiioa80OVSIIc0j+Jl2K6gUdk33NBUt2501cTl9NPW84fFLas7khw6lVuWpXZS4Eph 9yPwWKv6TAFPF2GOV8CL/aifFm3TolUQwfVxNDiJP3tAKTw6RP7B0BStFNVYGe7m5AEH nq2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=k9tdDx4tevBZYu34e0FF1R86AaQXWWnuGILrZlABPYM=; b=R2HoSdkHXl4kVzuh9P28sdtCaUr0WhbqeqbhWdnJLa4JOZR76WNI3lX4ZvmQ7UcQAo Zc8aYoaTE1BwI9Cb/ena1xn7276EarEpTe3KM5332EufD06HIxzPAX3G74WwlwFMMLwU 2OljX0il3ZUnPVrRS3ouh3vX+T+Vo0BsNReacw/hLR/ARYfVwsubVAl5/0QnXJ6s62f0 YicMnx1wyO14sXG0ZOD7Wsa0IFPMBmvXaKdaAoP4DKMQ31xiBcC6RPMKW5fL+ES4KEP8 jwzp25Pt+zUsPbC8Pr0BSTARwRmsino1b462Ls0IHjdfJuHC3xf4+M3nY/LRx5SO3MKF Bo1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=c4eX8iwj; dkim=neutral (no key) header.i=@suse.de header.b=2buHS59w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y62-20020a638a41000000b0041bb43fd038si17188974pgd.473.2022.08.24.02.59.47; Wed, 24 Aug 2022 02:59:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=c4eX8iwj; dkim=neutral (no key) header.i=@suse.de header.b=2buHS59w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235465AbiHXJm3 (ORCPT + 99 others); Wed, 24 Aug 2022 05:42:29 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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