Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp173601iob; Mon, 2 May 2022 16:16:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzF4CC/LfIoZOlt89o7SoCwuGiS/dd/mHccAF+xFKUnm0UKMoj3zJzKDd/QHjPy6BpE6nAH X-Received: by 2002:a17:90b:1c8f:b0:1b8:c6dc:ca61 with SMTP id oo15-20020a17090b1c8f00b001b8c6dcca61mr1617068pjb.13.1651533376655; Mon, 02 May 2022 16:16:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651533376; cv=none; d=google.com; s=arc-20160816; b=UUQtqLEXTIeeFekYjOV5AbJAXn/vEpNmo1M9A8qlwM0RENtkcXDbZGXCs+57nghQz5 q6dqORw8A5DY6zOZonZ8A2TWNfSKFZ4EFQ/EpRXZln51xnYrR16OfRMJSXP85zrV8WIk oo/ouIYMbt+THpRXtTLyXYxe5F95cn37siqG7izzsUYw9YBTpneQEFGMZL2VEeGEqLXQ QhqXc34xRKmdWvoqv/16rSrrqpygzM1OtMpiF4PmcqODgJAJa4VH9qGn/iFjDvUiZTIK 1hwPIE7zPooT90qKZE7jxAWtgCsdshxyFNWIWJzGillQYXJwTq1xgnyjEU0e29m8MJTu 30sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=1Zn4UF57t4pnfMwkACd31jjeal5RhpHnkwFarZTu/dQ=; b=Y6seLBs/44qBdVHyEP+NkNoFKKmIuzw07Xux6TGz36IPXTwG3Qb65UiNaDPhrf0qFa EVHIMC+iBUm2Fs8H29JYjWf5RPR3S+3/qOInqgsOhqvtixiHI/hblJiux1RJ/jSRVMK6 EBdAYZBAmuCdUNntpYBBhpdR7503Y+ym8hpOFbmHf2nNB2CBHi8xmTkD16+ReV7g8Ctl ypbb7c3x9VBg1dXciOPaqI4s8U566hZq2wLHEBfsp+W5sBNQ3bomtATRaCzaOezx+RSN /FF0iZrV6rdD/vfEW5qHnlWhYN287DCM3fZ10zqJbMkFLrS4T4YkK0wcpnBhaSbYxxj5 PNzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yju2gP3H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l25-20020a637c59000000b003ab6b928a08si15136475pgn.602.2022.05.02.16.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 16:16:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yju2gP3H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B08C62630; Mon, 2 May 2022 16:16:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379998AbiD2Scw (ORCPT + 99 others); Fri, 29 Apr 2022 14:32:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379995AbiD2Scu (ORCPT ); Fri, 29 Apr 2022 14:32:50 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0AE2D3AEC for ; Fri, 29 Apr 2022 11:29:29 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id r13so16989395ejd.5 for ; Fri, 29 Apr 2022 11:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=1Zn4UF57t4pnfMwkACd31jjeal5RhpHnkwFarZTu/dQ=; b=Yju2gP3H7feQ0jeMIY/hZkOEOoSoa00CEibfna6oVQzF9/eQ5+ytMAsdLe5WX7mHeQ J61qzVV7hJgD2E7DTMm799fD1ExZWC92O5Z5MQJ3Izz75VW5dcvN/q6CSgHUbws9RglY 83cEuaWdBuKpqQTXIrafNSDyCsuv2Ew28D74WXz/Ik2eST10Un3FzGmvqMC8O+fYL4PC 8JQYD4vG/i4KtH8ZMZH0GPFGUg6Nz8RKmYkXLtDfxBXypISaZi6+WTwWX/9LGj3oj9Ql L8++NV0TVRjT6Iqj0aHMEIgQOGyyJP0xnB5R1z3nGhE9kAKq1TuJQ1gQ5SW7rPZfWhCn o50w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=1Zn4UF57t4pnfMwkACd31jjeal5RhpHnkwFarZTu/dQ=; b=lIA0xq9et5qyc0kxO2IhatFSgi3sNqsnCdtt5he94ii0z+DfZfk1xxHIw2NHvhdIJQ 6Kb9XB9L42RAqjyJmQmQms/GssEKgyyDqVQBHZqRwQCOm9CE0H9mSf+3tFs5yW895wjM XkEBoFWOK8vfQnihfrm1gK1pNmgSd5FaKoDdSeo5bK2JmUmWMnTuz+1m87CA7XhJEStR umoEipKgPfnyh+k53P71vTfv1jagBEc72T0WsR07KEyDhRVcJzFBH7rzCjXrvbfgi0WD KkwkVJmh5JmYNZYtvuF0aRIqcrq2erlxMo9651raVmKtwp8mReAA7A1dg/8PvGOrQM69 j/Eg== X-Gm-Message-State: AOAM532ex9NIAwZ9QxxtrTmVkBDaZ9rfYu7oiih3lQ/SHwdzFUjumpJg SCvMNQpB38Mdy0ysQM3cnMNklQ== X-Received: by 2002:a17:907:2cc6:b0:6f0:2de3:9446 with SMTP id hg6-20020a1709072cc600b006f02de39446mr581569ejc.690.1651256968301; Fri, 29 Apr 2022 11:29:28 -0700 (PDT) Received: from [192.168.0.175] (xdsl-188-155-176-92.adslplus.ch. [188.155.176.92]) by smtp.gmail.com with ESMTPSA id h14-20020a1709070b0e00b006f3ef214db9sm858906ejl.31.2022.04.29.11.29.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Apr 2022 11:29:27 -0700 (PDT) Message-ID: Date: Fri, 29 Apr 2022 20:29:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v7 12/12] rpmsg: Fix kfree() of static memory on setting driver_override Content-Language: en-US To: Marek Szyprowski , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: Stuart Yoder , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Bjorn Helgaas , Bjorn Andersson , Mathieu Poirier , Vineeth Vijayan , Peter Oberparleiter , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Andy Gross , linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, NXP Linux Team , linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-spi@vger.kernel.org, virtualization@lists.linux-foundation.org, Linus Torvalds , Rasmus Villemoes , Andy Shevchenko References: <20220419113435.246203-1-krzysztof.kozlowski@linaro.org> <20220419113435.246203-13-krzysztof.kozlowski@linaro.org> <870885de-33f3-e0ba-4d56-71c3c993ac87@samsung.com> <75b94ccd-b739-2164-bc4a-20025356cc34@linaro.org> <6e21f7d3-49d0-eda7-7a89-0f8ac69596a4@samsung.com> From: Krzysztof Kozlowski In-Reply-To: <6e21f7d3-49d0-eda7-7a89-0f8ac69596a4@samsung.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/04/2022 16:51, Marek Szyprowski wrote: > On 29.04.2022 16:16, Krzysztof Kozlowski wrote: >> On 29/04/2022 14:29, Marek Szyprowski wrote: >>> On 19.04.2022 13:34, Krzysztof Kozlowski wrote: >>>> The driver_override field from platform driver should not be initialized >>>> from static memory (string literal) because the core later kfree() it, >>>> for example when driver_override is set via sysfs. >>>> >>>> Use dedicated helper to set driver_override properly. >>>> >>>> Fixes: 950a7388f02b ("rpmsg: Turn name service into a stand alone driver") >>>> Fixes: c0cdc19f84a4 ("rpmsg: Driver for user space endpoint interface") >>>> Signed-off-by: Krzysztof Kozlowski >>>> Reviewed-by: Bjorn Andersson >>> This patch landed recently in linux-next as commit 42cd402b8fd4 ("rpmsg: >>> Fix kfree() of static memory on setting driver_override"). In my tests I >>> found that it triggers the following issue during boot of the >>> DragonBoard410c SBC (arch/arm64/boot/dts/qcom/apq8016-sbc.dtb): >>> >>> ------------[ cut here ]------------ >>> DEBUG_LOCKS_WARN_ON(lock->magic != lock) >>> WARNING: CPU: 1 PID: 8 at kernel/locking/mutex.c:582 >>> __mutex_lock+0x1ec/0x430 >>> Modules linked in: >>> CPU: 1 PID: 8 Comm: kworker/u8:0 Not tainted 5.18.0-rc4-next-20220429 #11815 >>> Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) >>> Workqueue: events_unbound deferred_probe_work_func >>> pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) >>> pc : __mutex_lock+0x1ec/0x430 >>> lr : __mutex_lock+0x1ec/0x430 >>> .. >>> Call trace: >>>  __mutex_lock+0x1ec/0x430 >>>  mutex_lock_nested+0x38/0x64 >>>  driver_set_override+0x124/0x150 >>>  qcom_smd_register_edge+0x2a8/0x4ec >>>  qcom_smd_probe+0x54/0x80 >>>  platform_probe+0x68/0xe0 >>>  really_probe.part.0+0x9c/0x29c >>>  __driver_probe_device+0x98/0x144 >>>  driver_probe_device+0xac/0x14c >>>  __device_attach_driver+0xb8/0x120 >>>  bus_for_each_drv+0x78/0xd0 >>>  __device_attach+0xd8/0x180 >>>  device_initial_probe+0x14/0x20 >>>  bus_probe_device+0x9c/0xa4 >>>  deferred_probe_work_func+0x88/0xc4 >>>  process_one_work+0x288/0x6bc >>>  worker_thread+0x248/0x450 >>>  kthread+0x118/0x11c >>>  ret_from_fork+0x10/0x20 >>> irq event stamp: 3599 >>> hardirqs last  enabled at (3599): [] >>> _raw_spin_unlock_irqrestore+0x98/0x9c >>> hardirqs last disabled at (3598): [] >>> _raw_spin_lock_irqsave+0xc0/0xcc >>> softirqs last  enabled at (3554): [] _stext+0x470/0x5e8 >>> softirqs last disabled at (3549): [] >>> __irq_exit_rcu+0x180/0x1ac >>> ---[ end trace 0000000000000000 ]--- >>> >>> I don't see any direct relation between the $subject and the above log, >>> but reverting the $subject on top of linux next-20220429 hides/fixes it. >>> Maybe there is a kind of memory trashing somewhere there and your change >>> only revealed it? >> Thanks for the report. I think the error path of my patch is wrong - I >> should not kfree(rpdev->driver_override) from the rpmsg code. That's the >> only thing I see now... >> >> Could you test following patch and tell if it helps? >> https://pastebin.ubuntu.com/p/rp3q9Z5fXj/ > > This doesn't help, the issue is still reported. I think I screwed this part of code. The new helper uses device_lock() (the mutexes you see in backtrace) but in rpmsg it is called before device_register() which initializes the device. I don't have a device using qcom-smd rpmsg, so it's a bit tricky to reproduce. Best regards, Krzysztof