Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp798385rdb; Tue, 5 Dec 2023 23:21:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuWhVbpW0CrA3nN63ObsEFosFtkf7yTAJMQL5UCLUanL8IZ/e/xC6luuuHbhP19VHQD/xs X-Received: by 2002:a05:6808:2789:b0:3b8:b063:8275 with SMTP id es9-20020a056808278900b003b8b0638275mr519881oib.119.1701847264140; Tue, 05 Dec 2023 23:21:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701847264; cv=none; d=google.com; s=arc-20160816; b=rDly7hRyBs1eUDnB557s7AC5Ia5u/g71BBvgljqSBkttxxJ4+JExe8278VN0hO9jvN QYG2rHVXUp0iYYbx2Nc7/i976O2eANqCCVe50ihfPb9ObRtrOtjBbol9vAxuU7RCz9hI jwUDSCyEl0++lmpdUPOCKX8Afw50bDeLeOV6tPuP0Hl8wWSctQ/Y3T9FK8I2fdSK1wCV +upxV19MbQNsS1QVdk+mEuK7vTchMhgJ5SiwNtvQpQLLqyJ7GzYaZ/QEJkMuCo/CuFEi PrGTWa0gcvg/g2LdSKxmyUc7OKnjQazasKc4evE5PnW+jkhgecZNeWB3/xWemZLsaZwF +R+g== 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; bh=AbONOCkKXOYcZwRK6ElQrGF9qOJ9SBNp9IeRLPfvkYs=; fh=e10s9mvEmIwNktmFKcvLp+5q13zMaXrrSH+l3pFAFpw=; b=Gc5DWFELm2VCbi4CiISdZsoBC4zMuFw7ZFdvyylIHl9g7B8WG+KAFVMKGFigiu7D2k GEASRbGZyrELXWuxdX8ROw62xr3Tjr5jPRP1xnI+mAT51iY+UjzvT6c3OlbrWYkbxvNQ ajPctaZsaXBlQ8AoifJ8pfOt6LJSvj+sBcuVVkz8r7ZUnXfqfqlx1X0rqIwrWSKUkyz9 ndbuetJAJM9KlKojhbKVqOtIrWO5JBl7NQy+mifjvUoLgxI7TALGB3CWLV/DH8uJzE9f Xonq6oUF8ka6FFi63rTffCLZ3K3hdo93jAG8GkIfpZU7KNnS1kHftozL+SQ4TT2nmFHq lPPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id n3-20020a632703000000b005c6666dcce1si6612844pgn.583.2023.12.05.23.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 23:21:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 2344382D1A94; Tue, 5 Dec 2023 23:21:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377018AbjLFHUq (ORCPT + 99 others); Wed, 6 Dec 2023 02:20:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376923AbjLFHUo (ORCPT ); Wed, 6 Dec 2023 02:20:44 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C2F5D40; Tue, 5 Dec 2023 23:20:50 -0800 (PST) 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-out1.suse.de (Postfix) with ESMTPS id 0361722054; Wed, 6 Dec 2023 07:20:49 +0000 (UTC) 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 BDBB513408; Wed, 6 Dec 2023 07:20:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id VdM1LNAgcGVrFAAAD6G6ig (envelope-from ); Wed, 06 Dec 2023 07:20:48 +0000 Date: Wed, 06 Dec 2023 08:20:48 +0100 Message-ID: <87cyvj3igf.wl-tiwai@suse.de> From: Takashi Iwai To: Jason Zhang Cc: perex@perex.cz, tiwai@suse.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: pcm: fix out-of-bounds in snd_pcm_state_names In-Reply-To: <20231206013139.20506-1-jason.zhang@rock-chips.com> References: <20231206013139.20506-1-jason.zhang@rock-chips.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-Score: 3.98 X-Spamd-Result: default: False [3.98 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(2.99)[0.997]; MIME_GOOD(-0.10)[text/plain]; R_SPF_SOFTFAIL(0.00)[~all]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[37.16%]; DMARC_POLICY_SOFTFAIL(0.10)[suse.de : No valid SPF, No valid DKIM,none] X-Spamd-Bar: +++ X-Rspamd-Server: rspamd1 Authentication-Results: smtp-out1.suse.de; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=suse.de (policy=none); spf=softfail (smtp-out1.suse.de: 2a07:de40:b281:104:10:150:64:97 is neither permitted nor denied by domain of tiwai@suse.de) smtp.mailfrom=tiwai@suse.de X-Rspamd-Queue-Id: 0361722054 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 05 Dec 2023 23:21:01 -0800 (PST) On Wed, 06 Dec 2023 02:31:39 +0100, Jason Zhang wrote: > > The pcm state can be SNDRV_PCM_STATE_DISCONNECTED at disconnect > callback, and there is not an entry of SNDRV_PCM_STATE_DISCONNECTED > in snd_pcm_state_names. > > This patch adds the missing entry to resolve this issue. > > cat /proc/asound/card2/pcm0p/sub0/status > That results in stack traces like the following: > > [ 99.702732][ T5171] Unexpected kernel BRK exception at EL1 > [ 99.702774][ T5171] Internal error: BRK handler: f2005512 [#1] PREEMPT SMP > [ 99.703858][ T5171] Modules linked in: bcmdhd(E) (...) > [ 99.747425][ T5171] CPU: 3 PID: 5171 Comm: cat Tainted: G C OE 5.10.189-android13-4-00003-g4a17384380d8-ab11086999 #1 > [ 99.748447][ T5171] Hardware name: Rockchip RK3588 CVTE V10 Board (DT) > [ 99.749024][ T5171] pstate: 60400005 (nZCv daif +PAN -UAO -TCO BTYPE=--) > [ 99.749616][ T5171] pc : snd_pcm_substream_proc_status_read+0x264/0x2bc > [ 99.750204][ T5171] lr : snd_pcm_substream_proc_status_read+0xa4/0x2bc > [ 99.750778][ T5171] sp : ffffffc0175abae0 > [ 99.751132][ T5171] x29: ffffffc0175abb80 x28: ffffffc009a2c498 > [ 99.751665][ T5171] x27: 0000000000000001 x26: ffffff810cbae6e8 > [ 99.752199][ T5171] x25: 0000000000400cc0 x24: ffffffc0175abc60 > [ 99.752729][ T5171] x23: 0000000000000000 x22: ffffff802f558400 > [ 99.753263][ T5171] x21: ffffff81d8d8ff00 x20: ffffff81020cdc00 > [ 99.753795][ T5171] x19: ffffff802d110000 x18: ffffffc014fbd058 > [ 99.754326][ T5171] x17: 0000000000000000 x16: 0000000000000000 > [ 99.754861][ T5171] x15: 000000000000c276 x14: ffffffff9a976fda > [ 99.755392][ T5171] x13: 0000000065689089 x12: 000000000000d72e > [ 99.755923][ T5171] x11: ffffff802d110000 x10: 00000000000000e0 > [ 99.756457][ T5171] x9 : 9c431600c8385d00 x8 : 0000000000000008 > [ 99.756990][ T5171] x7 : 0000000000000000 x6 : 000000000000003f > [ 99.757522][ T5171] x5 : 0000000000000040 x4 : ffffffc0175abb70 > [ 99.758056][ T5171] x3 : 0000000000000001 x2 : 0000000000000001 > [ 99.758588][ T5171] x1 : 0000000000000000 x0 : 0000000000000000 > [ 99.759123][ T5171] Call trace: > [ 99.759404][ T5171] snd_pcm_substream_proc_status_read+0x264/0x2bc > [ 99.759958][ T5171] snd_info_seq_show+0x54/0xa4 > [ 99.760370][ T5171] seq_read_iter+0x19c/0x7d4 > [ 99.760770][ T5171] seq_read+0xf0/0x128 > [ 99.761117][ T5171] proc_reg_read+0x100/0x1f8 > [ 99.761515][ T5171] vfs_read+0xf4/0x354 > [ 99.761869][ T5171] ksys_read+0x7c/0x148 > [ 99.762226][ T5171] __arm64_sys_read+0x20/0x30 > [ 99.762625][ T5171] el0_svc_common+0xd0/0x1e4 > [ 99.763023][ T5171] el0_svc+0x28/0x98 > [ 99.763358][ T5171] el0_sync_handler+0x8c/0xf0 > [ 99.763759][ T5171] el0_sync+0x1b8/0x1c0 > [ 99.764118][ T5171] Code: d65f03c0 b9406102 17ffffae 94191565 (d42aa240) > [ 99.764715][ T5171] ---[ end trace 1eeffa3e17c58e10 ]--- > [ 99.780720][ T5171] Kernel panic - not syncing: BRK handler: Fatal exception > > Signed-off-by: Jason Zhang Thanks, applied now. We should add range checks at the helper functions that access the arrays, too. I'll submit the patch later. Takashi