Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1263991rwr; Wed, 3 May 2023 12:28:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4FG03Z/1gS6HCRmUKdEa5osyaetxXVg976l0tMk53SfeVHNgfsEuPtt/ZYIj5WbL0oQmoI X-Received: by 2002:a05:6a00:13a2:b0:640:da6d:bdc7 with SMTP id t34-20020a056a0013a200b00640da6dbdc7mr33190426pfg.33.1683142131774; Wed, 03 May 2023 12:28:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683142131; cv=none; d=google.com; s=arc-20160816; b=mv4But7JCw8/YLrqCR+ruttc0dwn4MbSI7N5Fq8Kb10Qja/g62JAljnD4B+rdGrTvT vKS4Sxbuxe8RHs4N67BwLfKYuvx5oyRaXI75P6YFD7vbg1h8gMtnRArAfAEqrBL5DhFP TuO7HZ/FTEednGCdU0M4tKDCNim3d+g9gVjidWWGFcHbc+xq9nGBTPsEukg0g3FIUBFK jTgspCZ8Ao5lCHSytIAEXcw3LizoNbP9CDvqN5YvzBWPPzINA03A7BPtD8rDJBOWDWq4 cZefodySu6Z5D0wVa77lhvsW/ccF7M1Zhd2rNmb+jOjrg/9QnsXv73M2YJ0Jai66EbG2 cSiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from; bh=hmJuAmsSrf1JxTtAScWx0Qm2zDbDU2w+3iSrmXewC/c=; b=TX3ZKWYe0N8i089lEOa9/EVLIrKoVV4bxIlLi0kPmn58CnmiEkhMU3jCuS0m4rwPdb R+5dri1SB3eTHZYK3hqBd/1S20J5S5fFRMjb0N+myWbw1D5IuIYtBhVwLVLyBGjEE/vD kIbEOZaOhm2ZLx7+P3DTe5aHrEOqTB80dIjj5zVMGWoJ7VclnP8I9dADE/X4aHzd8xjc PMgO9BxiPPS+KVNFRYkJa6GmmO+zl6yo1dsRPNzNDNpTOYl1lKwJAMaGEsKGXRcbCv17 FmVqs3BB8/9lfZ0ZoP2gkLl/UX1RK16Savqs4ChRHYVDMsrWLT66wDN8Sl0UpZURSq6f HgMw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f16-20020a63f110000000b00524da606617si30241583pgi.233.2023.05.03.12.28.40; Wed, 03 May 2023 12:28:51 -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; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229722AbjECTOH (ORCPT + 99 others); Wed, 3 May 2023 15:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbjECTOF (ORCPT ); Wed, 3 May 2023 15:14:05 -0400 Received: from fgw23-7.mail.saunalahti.fi (fgw23-7.mail.saunalahti.fi [62.142.5.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B59D87690 for ; Wed, 3 May 2023 12:14:04 -0700 (PDT) Received: from localhost (88-113-26-95.elisa-laajakaista.fi [88.113.26.95]) by fgw23.mail.saunalahti.fi (Halon) with ESMTP id a912b3f3-e9e6-11ed-b972-005056bdfda7; Wed, 03 May 2023 22:14:01 +0300 (EEST) From: andy.shevchenko@gmail.com Date: Wed, 3 May 2023 22:14:00 +0300 To: Xiaolei Wang Cc: aisheng.dong@nxp.com, festevam@gmail.com, shawnguo@kernel.org, ping.bai@nxp.com, kernel@pengutronix.de, linus.walleij@linaro.org, shenwei.wang@nxp.com, bartosz.golaszewski@linaro.org, peng.fan@nxp.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [v2][PATCH] pinctrl: freescale: Fix a memory out of bounds when num_configs is 1 Message-ID: References: <20230503012127.4157304-1-xiaolei.wang@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230503012127.4157304-1-xiaolei.wang@windriver.com> X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,SPF_HELO_NONE, SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no 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 Wed, May 03, 2023 at 09:21:27AM +0800, Xiaolei Wang kirjoitti: > The config passed in by pad wakeup is 1, When num_configs is 1, > configs[1] should not be obtained, which will generate the > following memory out-of-bounds situation: > > BUG: KASAN: stack out of bounds in imx_pinconf_set_scu+0x9c/0x160 > Read size 8 at address ffff8000104c7558 by task sh/664 > CPU: 3 PID: 664 Communication: sh Tainted: G WC 6.1.20 #1 > Hardware name: Freescale i.MX8QM MEK (DT) > Call trace: > dump_backtrace.part.0+0xe0/0xf0 > show stack+0x18/0x30 > dump_stack_lvl+0x64/0x80 > print report +0x154/0x458 > kasan_report+0xb8/0x100 > __asan_load8+0x80/0xac > imx_pinconf_set_scu+0x9c/0x160 > imx_pinconf_set+0x6c/0x214 > pinconf_set_config+0x68/0x90 > pinctrl_gpio_set_config+0x138/0x170 > gpiochip_generic_config+0x44/0x60 > mxc_gpio_set_pad_wakeup+0x100/0x140 > mxc_gpio_noirq_suspend+0x50/0x74 > pm_generic_suspend_noirq+0x4c/0x70 > genpd_finish_suspend+0x174/0x260 > genpd_suspend_noirq+0x14/0x20 > dpm_run_callback.constprop.0+0x48/0xec > __device_suspend_noirq+0x1a8/0x370 > dpm_noirq_suspend_devices+0x1cc/0x320 > dpm_suspend_noirq+0x7c/0x11c > suspend_devices_and_enter+0x27c/0x760 > pm_suspend+0x36c/0x3e0 I have already pointed out to the documentation in which you may find what to do to make above better. > Fixes: f60c9eac54af ("gpio: mxc: enable pad wakeup on i.MX8x platforms") > Signed-off-by: Xiaolei Wang > --- Where is the changelog? -- With Best Regards, Andy Shevchenko