Received: by 2002:a05:7412:3210:b0:e2:908c:2ebd with SMTP id eu16csp829444rdb; Fri, 1 Sep 2023 05:38:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiNf0r08j5862bVhOsdo747xGhd/C31y7R/nPYpbeKF17BIaHuXAxZyJ7qJ7rrB5BwvRmy X-Received: by 2002:aa7:ce19:0:b0:523:cc3d:9121 with SMTP id d25-20020aa7ce19000000b00523cc3d9121mr2045813edv.14.1693571899283; Fri, 01 Sep 2023 05:38:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693571899; cv=none; d=google.com; s=arc-20160816; b=qhJd2xwJ5Q9ngBPFNEXLuPK0kkH7lvoEsbRe2Of1L7ktKlLkEtKX4g/ayAzC2OkjlF LhnLaUzBywMqmYCcINSPOEvp6TefUgsMjrQ+vDQXq41wvPbI7stFop+0hPyccn5Guxsm 0QQSejG0zdH1eiktztExbL8He9Syf06YrzQxQnNct4FYjoUFBJpKR6i2YwhLNa4o/5Tk AmTV4wa8a+3hneN/ieFpPTlUV/Sj4Q7V3e9u0kCGnd2vidA1aMtmu9NhY9xbmlMBPkX9 WLPam8KyiEe4LxfBZEcytplXRa4zT5f5UVSugMhqBX+xXG5P+TY562YF8zdwnJkoYEfL W6lg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=/fyiVCyXV2/DWi8HCTGCvDw4YItjkimq+ZGM7Jptvjw=; fh=MJubmxAXSZkEQ5P4pvdmrVEhTRZicl7hq89mEgzPERU=; b=gq8TqwKdPEhWkUK4i/OLkrvNlzkVhmljzuvozTV3A+q8x4SQUIH7VIkpGGnb024R/E efyDeLWmXjEpUNMtpvXawfDTJEsxNDxwXt1jiq8iLLnkyHlrEkXpAARzCbXmLq9PE3Lq y/5KBfqU1/R0joLc0uqJE9OzSaBjA6DDFs++teUYmeRS+W7kwbq4AljseW2jtr+ofFZj WfwQHsMA/Xkh6515CHTXEQwdpeq3e9OpVl1AWNwjJLEaFIo5MR3wjY1IVABmdDwwGoip 3XpjD+FhxdACDYoF95WsN+jdE7HPstqSCUG8PKW95eNd27gzWqsbh8DX2m0LBO3evECd whBw== 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=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a50fc05000000b0052a24da0793si2350690edr.346.2023.09.01.05.38.11; Fri, 01 Sep 2023 05:38:19 -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=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346264AbjHaMeT (ORCPT + 29 others); Thu, 31 Aug 2023 08:34:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231956AbjHaMeT (ORCPT ); Thu, 31 Aug 2023 08:34:19 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E19DC19A for ; Thu, 31 Aug 2023 05:34:15 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F3D83C15; Thu, 31 Aug 2023 05:34:54 -0700 (PDT) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C333A3F738; Thu, 31 Aug 2023 05:34:14 -0700 (PDT) Date: Thu, 31 Aug 2023 13:34:12 +0100 From: Sudeep Holla To: Qiujun Huang Cc: cristian.marussi@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] firmware: arm_scmi: Fix NULL pointer dereference in mailbox_clear_channel Message-ID: <20230831123412.wetnqqb7owqfyqov@bogus> References: <20230830093902.duvvjimgwddh7qbt@bogus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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, Aug 30, 2023 at 09:23:58PM +0800, Qiujun Huang wrote: > > > > 2023年8月30日 下午5:39,Sudeep Holla 写道: > > > > On Wed, Aug 30, 2023 at 01:07:47AM +0800, Qiujun Huang wrote: > >> There is a race between the failure of probe and rx_callback (due to a > >> delayed response). > >> > >> scmi_probe > >> scmi_acquire_protocal > >> do_xfer > >> timeout > >> mailbox_chan_free > >> <--- delay response > >> rx_callback > >> mbox_free_channel > >> cinfo->transport_info = NULL > >> mailbox_clear_channel > >> dereference cinfo->transport_info > > > > It is always good to provide the kernel stacktrace which you get when a > > NULL pointer is dereference. It helps for review and also to document it. > > > > -- > > Regards, > > Sudeep > > Get it. Here is the splat. > > [ 1.942240][ C0] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000048 > [ 1.942241][ C0] Mem abort info: > [ 1.942243][ C0] ESR = 0x96000005 > [ 1.944888][ T9] spmi spmi-1: PMIC arbiter version v7 (0x70000000) > [ 1.950652][ C0] EC = 0x25: DABT (current EL), IL = 32 bits > [ 1.950653][ C0] SET = 0, FnV = 0 > [ 1.950654][ C0] EA = 0, S1PTW = 0 > [ 1.950656][ C0] Data abort info: > [ 1.950657][ C0] ISV = 0, ISS = 0x00000005 > [ 1.950658][ C0] CM = 0, WnR = 0 > [ 1.950660][ C0] [0000000000000048] user address but active_mm is swapper > [ 1.950663][ C0] Internal error: Oops: 96000005 [#1] PREEMPT SMP > [ 2.338929][ C0] pc : mailbox_clear_channel+0x18/0x64 > [ 2.344384][ C0] lr : scmi_handle_response+0x17c/0x4f4 > [ 2.349923][ C0] sp : ffffffc010003db0 > [ 2.354045][ C0] x29: ffffffc010003dc0 x28: ffffffd85263f000 > [ 2.360216][ C0] x27: ffffffd851621068 x26: ffffffd84ec815c8 > [ 2.366386][ C0] x25: ffffffd85263bf80 x24: ffffffd85263d230 > [ 2.372556][ C0] x23: ffffff803cd70cc0 x22: 0000000000000008 > [ 2.378726][ C0] x21: ffffff8036cf0df8 x20: ffffffd85161bac8 > [ 2.384896][ C0] x19: ffffff8043ffa580 x18: ffffffc010005050 > [ 2.391065][ C0] x17: 0000000000000000 x16: 00000000000000d8 > [ 2.397234][ C0] x15: ffffffd8507965e8 x14: ffffffd84eaebdf0 > [ 2.403404][ C0] x13: 00000000000001ea x12: 0000000000007ffb > [ 2.409574][ C0] x11: 000000000000ffff x10: ffffffd852c5a000 > [ 2.415744][ C0] x9 : d7be1a9b75f29500 x8 : 0000000000000000 > [ 2.421914][ C0] x7 : 382e31202020205b x6 : ffffffd852c57e7c > [ 2.428084][ C0] x5 : ffffffffffffffff x4 : 0000000000000000 > [ 2.434254][ C0] x3 : ffffffd84eae6668 x2 : 0000000000000001 > [ 2.440424][ C0] x1 : 0000000000000000 x0 : ffffff8043ffa580 > [ 2.446594][ C0] Call trace: > [ 2.449819][ C0] mailbox_clear_channel+0x18/0x64 Is this with latest kernel ? IIUC the mailbox_clear_channel should get called only for delayed response and notification in this path(scmi_handle_response). You are saying it happens as part of probe and again IIUC probe doesn't have any delayed response command. What am I missing ? Any additional changes in the tree ? My build has much smaller mailbox_clear_channel. > [ 2.454916][ C0] scmi_handle_response+0x17c/0x4f4 > [ 2.460100][ C0] rx_callback+0x60/0xec > [ 2.464311][ C0] mbox_chan_received_data+0x44/0x94 > [ 2.469584][ C0] qcom_rimps_rx_interrupt+0xc0/0x144 [qcom_rimps] This suggests out of tree driver, any pointers ? Also I vaguely remember discussing this in the past. Perhaps at [1] or somewhere else. -- Regards, Sudeep [1] https://lore.kernel.org/linux-arm-kernel/cfa26ff3-c95a-1986-58fc-b49fc9be49d5@quicinc.com/