Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8216818rwb; Tue, 13 Dec 2022 03:51:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf5TND6+/UCZ8aA+OILdARxMAmbhpMDeiI9h6Cduj1gYHShJ8WPOJSiWC8eVS8fP/1pBEfqm X-Received: by 2002:a17:90a:1504:b0:219:6a87:bd09 with SMTP id l4-20020a17090a150400b002196a87bd09mr22988430pja.18.1670932312859; Tue, 13 Dec 2022 03:51:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670932312; cv=none; d=google.com; s=arc-20160816; b=Fv4XryngNfappWXNnoGkQGaN2YHISg3O6rZtudy4w3i097JpgCHR+eS5VaaIcyT+wd m2zRyHGoCT0S5UrUL1BUC+xq7VPAex0MkT9M4lvHfygbqRlJZfDyOGgaR+0EPu4Jboov jm1VZj+ZQvVZNGNvo3tjbjGau/HnBV8gBeDj11cA7YySmIoW5J+oWEgq3v/nhiMvXDcE lyeVwE0AmVwyUk7w2Wj/kgrDFCU1zZHegxxyCogzfokE9Tg7toVPXtlVwVKJ/1C7aLI+ fvGIcN86f7hksSK+FjllsgBp4Av80U6HaFTtp+u0LEEXWJ0YbI8TWrWJpI/XSqHM1nux aF2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :in-reply-to:from:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature:dkim-filter; bh=GWlKbT51HpBnFtB9eCRCm5UsJLYbwGnOyZSuSyWXyvM=; b=tjwySMlbsFnox3eOlXW6Mi5HeloYquCJo8SVvB8+xshB3TM1LnRcmN32GaPo2j93g1 sy3XO0OjCZvYnnNpqbHOyyyf4xx/2XPbBwM014UDEFbj1xIU0RRQivEOTcHZm3eEK9sz HMNYQBo/wtI8nB4fIYqv/WSyzMZT+3mB27swTn664eYDY7eu2xYSAMgiM1ZyarOwftyJ lSfw1513dQvC7rzWJ+q2WAwSoFcgaHFk3xhmt9ftKlzfgHXYhv6tO/GLaO65Oj/9jNT6 hpaggjq4uHsPv5ytYoR6elfe0FQoT4CkelzqmjEdsFmE7DYBFwB+Ubls/G455A3BYjz3 5pnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=lykxvOOW; 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=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ng7-20020a17090b1a8700b00202b984842csi14223610pjb.35.2022.12.13.03.51.43; Tue, 13 Dec 2022 03:51:52 -0800 (PST) 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=@samsung.com header.s=mail20170921 header.b=lykxvOOW; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235102AbiLMLdI (ORCPT + 73 others); Tue, 13 Dec 2022 06:33:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234860AbiLMLdF (ORCPT ); Tue, 13 Dec 2022 06:33:05 -0500 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81CDD167F3 for ; Tue, 13 Dec 2022 03:33:02 -0800 (PST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20221213113300euoutp01f0bcc1aceee2a6e25af5ac768a7c73a1~wVw5L5VLt3119231192euoutp01h for ; Tue, 13 Dec 2022 11:33:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20221213113300euoutp01f0bcc1aceee2a6e25af5ac768a7c73a1~wVw5L5VLt3119231192euoutp01h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1670931180; bh=GWlKbT51HpBnFtB9eCRCm5UsJLYbwGnOyZSuSyWXyvM=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=lykxvOOWrPLcoQWKnCUpxzd8v63GXoViLw1kWm923K3eiW4QskfN+7A/tIntPJQhf Unx8rVwXWeLDtw0Nm6Z84Z5obACUsZpI6RzUaGcgA9taQqkhh/eFW1gsKrcGJu22TK YDS952CdY7cxZyIp40HoG7xpkxrWLsurd2TASYJo= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20221213113300eucas1p17d6efbbc2bf2ab5d4468a96368a2cefe~wVw4xrkuC3106731067eucas1p1t; Tue, 13 Dec 2022 11:33:00 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 59.43.09549.CE268936; Tue, 13 Dec 2022 11:33:00 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20221213113259eucas1p1c224898772bc5e59de90c1aa65a34de0~wVw4Uxwi00626006260eucas1p1y; Tue, 13 Dec 2022 11:32:59 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221213113259eusmtrp291348dac2ff05b31a5224d1aa6f304b1~wVw4T0FQ03275132751eusmtrp27; Tue, 13 Dec 2022 11:32:59 +0000 (GMT) X-AuditID: cbfec7f5-f5dff7000000254d-69-639862ec7628 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 7E.0A.09026.BE268936; Tue, 13 Dec 2022 11:32:59 +0000 (GMT) Received: from [106.210.134.192] (unknown [106.210.134.192]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20221213113258eusmtip2cc0370484eb751b7e520ae3161b23a98~wVw3ZMnhV0156401564eusmtip2h; Tue, 13 Dec 2022 11:32:58 +0000 (GMT) Message-ID: Date: Tue, 13 Dec 2022 12:32:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH v2] regulator: core: Use different devices for resource allocation and DT lookup Content-Language: en-US To: cy_huang , broonie@kernel.org Cc: djrscally@gmail.com, hdegoede@redhat.com, markgross@kernel.org, lgirdwood@gmail.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, yangyingliang@huawei.com, gene_chen@richtek.com, chiaen_wu@richtek.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, ChiYuan Huang From: Marek Szyprowski In-Reply-To: <1670311341-32664-1-git-send-email-u0084500@gmail.com> Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDKsWRmVeSWpSXmKPExsWy7djPc7pvkmYkGxxaz27x8+U0RoupD5+w Waw9qW/xZU8/q8W2w+9YLZ70nGO1eHN8OpPFtysdTBabHl9jtbi8aw6bRde1J6wWB6ZOY7aY 93ctq8XqPS+YLSatu8dkseXTNSYHAY+n/VvZPXbOusvu0XLkLavHplWdbB6bl9R7vN93lc1j xqcpbB4H9xl6fN4kF8AZxWWTkpqTWZZapG+XwJXxcp5QwSKxiq9fH7A0MP4U6GLk5JAQMJFY 8+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de90c1aa65a34de0 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20221213113259eucas1p1c224898772bc5e59de90c1aa65a34de0 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221213113259eucas1p1c224898772bc5e59de90c1aa65a34de0 References: <1670311341-32664-1-git-send-email-u0084500@gmail.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS 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 Dear All, On 06.12.2022 08:22, cy_huang wrote: > From: ChiYuan Huang > > Following by the below discussion, there's the potential UAF issue > between regulator and mfd. > https://lore.kernel.org/all/20221128143601.1698148-1-yangyingliang@huawei.com/ > > >From the analysis of Yingliang > > CPU A |CPU B > mt6370_probe() | > devm_mfd_add_devices() | > |mt6370_regulator_probe() > | regulator_register() > | //allocate init_data and add it to devres > | regulator_of_get_init_data() > i2c_unregister_device() | > device_del() | > devres_release_all() | > // init_data is freed | > release_nodes() | > | // using init_data causes UAF > | regulator_register() > > It's common to use mfd core to create child device for the regulator. > In order to do the DT lookup for init data, the child that registered > the regulator would pass its parent as the parameter. And this causes > init data resource allocated to its parent, not itself. The issue happen > when parent device is going to release and regulator core is still doing > some operation of init data constraint for the regulator of child device. > > To fix it, this patch expand 'regulator_register' API to use the > different devices for init data allocation and DT lookup. > > Reported-by: Yang Yingliang > Signed-off-by: ChiYuan Huang This patch landed in linux-next 202212 as commit 8f3cbcd6b440 ("regulator: core: Use different devices for resource allocation and DT lookup"). Unfortunately it causes serious regression on my test systems. It looks that some supplies are not resolved correctly and then turned off as 'unused', even if they provide power to other core regulators in the system. I've observed this issue on Samsung Chromebook Peach-Pit and Peach-Pi (ARM 32bit Exynos based). The symptoms are somehow similar to the issue reported here some time ago: https://lore.kernel.org/all/58b92e75-f373-dae7-7031-8abd465bb874@samsung.com/ I've post more information once I analyze this issue further. > --- > loop Yang Yingliang in cc list. > > Since v2 > - Fix typo 'int3742' to 'int3472' for kernel build test > > --- > drivers/platform/x86/intel/int3472/clk_and_regulator.c | 3 ++- > drivers/regulator/core.c | 8 ++++---- > drivers/regulator/devres.c | 2 +- > drivers/regulator/of_regulator.c | 2 +- > drivers/regulator/stm32-vrefbuf.c | 2 +- > include/linux/regulator/driver.h | 3 ++- > 6 files changed, 11 insertions(+), 9 deletions(-) > > ... Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland