Received: by 10.192.165.148 with SMTP id m20csp1356928imm; Wed, 25 Apr 2018 17:33:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/isbRj/uZRyKoxfvQ7fQxMABvXPh/Xi3A26riMjUKhnVhDqqvPqLbZtT4NDC6ZbdrSnqKJ X-Received: by 2002:a17:902:2f43:: with SMTP id s61-v6mr27157431plb.99.1524702805825; Wed, 25 Apr 2018 17:33:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524702805; cv=none; d=google.com; s=arc-20160816; b=DyVzORvjfkYYfspvI91/9XxL1yKpYw3BOETmDb8TYgcvnhtVD5RW21Pm87DlEYxJI5 6a2WJhSKTjI2kkWAsJgtwxCdi+Dl/ntRZ3zoVmJleyVeuaamMNJO6OCjTS7nv4kT5JlU 25BvuRO7FD5/e5aWRfHszUWklvJLjmlii4Om2Cjo4abRUWt0oSfvAcEzLinFTOWOAz9T k0r3XL3gs0PoHq62tVm+RfAGo/867GRu8POAWEftumldoVX9kmK6ESPod88ylWBrsPKz rW4Eg8/XBb1UJqlzp0rw7EpiM6EU61Bh+6xNPuei+A9sRXWBugwLE5eyVMLg6b0HYm8s GGMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature :arc-authentication-results; bh=mq4NkLDOHptd5QkGYmAVqrgrTzOU0i2FWbDyia4rTQc=; b=rJ+C/gr+rVRAL+/yjQ9qF3mCHKCsbeC9ysjqv41Cie0kkeqX/rQosWWGZ8Ftw/SaH2 uBWrIVRR5tRudAE2X/Jkir2bAS8Mg87zW8IOqt40pYJPV6Xmh5y/NwmNHbRSKSWUilDq UGzF/P1flyyQdkeDob2BpRbKMy46A58VXV1dLwnayUF3I2ZIvzWvOUINaVviTekVki3U XTm35AdQTmbzGTvyLgoIuWn/SX9mYhobM8DYCN2ozGnKLoPziDO9alWr682rrWdyaBTQ PS1smhDMMBOUVMIx6gFHtgUoUR20GnYV7je17XekscE5zoLqECNp7RYFACUsaSsZe1zt DhCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pVoV2v+Z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi5-v6si4362978plb.399.2018.04.25.17.33.11; Wed, 25 Apr 2018 17:33:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pVoV2v+Z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751785AbeDZAcL (ORCPT + 99 others); Wed, 25 Apr 2018 20:32:11 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:45739 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751298AbeDZAcH (ORCPT ); Wed, 25 Apr 2018 20:32:07 -0400 Received: by mail-pf0-f194.google.com with SMTP id l27so16669298pfk.12; Wed, 25 Apr 2018 17:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=mq4NkLDOHptd5QkGYmAVqrgrTzOU0i2FWbDyia4rTQc=; b=pVoV2v+Zqxru+lhI4YKfbqX5RcGo/UaPl/1D9h+/YFVYd9mIAEkuUMhLyAl6UJKEnY pjzXAPLf/LcxCtuIbizGwq8YUR9R9g3hH8tug9f2/4TDnnTz2YStnzrREDl6kC18agJT WJLkLmtEorsPqAXuI5M4X8lf+aLe1mY3mU3qJvCRvcmnDnYR4zXNuyegY/V4ckeZ64Ez 0Gv6g5Aygr66w/armffS5kXfRMXTKogz+CyhS1R6ACWCAzyzUdiYxUX5Co2FeIhUukra WB85YYeYdkn49bjajpEh2k7XdY7WrcD51HQGBRczAEYxBkZ0umQJOPq+eaJ42cg4wqLt o2+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=mq4NkLDOHptd5QkGYmAVqrgrTzOU0i2FWbDyia4rTQc=; b=dHSwxHeivKw0J0W5S3sixM8GBuSTAmT/JWnjycjlUnjE/EPYPk9Pi1xFd9E4i1d19E /Jm6gQELFm419laeEw9ToP5lmvTJn1mDCYDgGajfOn4jaexIslgi5l9ClKS7LftYXR6p zcBQJvIAmAmO/tpyUWevxmAq9xKDyvrPXXUv+sx5rLIXkxFMDM3IN7Upi4ztmImFjJwg FLmlDuRZHyfzYJD9o7WgHXbWzmJRAUFXPf6BZZHMIBSyOvOSJO+0cE56C1mXKthb8/gM +WzTMZPW/SfNIFPJzqueGjFBzimFJHeC8+cl1TNwMYqNhxzBI1cCx1L7APhQu1pBifDR N87A== X-Gm-Message-State: ALQs6tDRNHgY8pqB2BcHo6PPaqOEejbJI8+LdF2oUT1rGW/1q9d60eAC S4emwjgXZFSyl2ZRGXrUk54= X-Received: by 2002:a17:902:8e8c:: with SMTP id bg12-v6mr30916196plb.295.1524702727150; Wed, 25 Apr 2018 17:32:07 -0700 (PDT) Received: from [192.168.1.70] (c-24-6-192-50.hsd1.ca.comcast.net. [24.6.192.50]) by smtp.gmail.com with ESMTPSA id z78sm44305107pfd.23.2018.04.25.17.32.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 17:32:06 -0700 (PDT) Subject: Re: [PATCH] of: overlay: Stop leaking resources on overlay removal From: Frank Rowand To: Jan Kiszka , Pantelis Antoniou , Rob Herring , devicetree Cc: Linux Kernel Mailing List , Alan Tull References: <097f1b01-6cb4-8dcb-0498-7b4c59a7ea53@siemens.com> <7aca82c1-a02c-2f84-bc32-6e8a118ba601@gmail.com> <90e7da9d-d40a-17f1-e627-873f58a3dce5@siemens.com> Message-ID: <17561711-94f7-b3d4-8f06-9cfa69daaf23@gmail.com> Date: Wed, 25 Apr 2018 17:32:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jan, On 04/24/18 13:58, Frank Rowand wrote: > On 04/24/18 10:50, Jan Kiszka wrote: >> On 2018-04-24 19:44, Frank Rowand wrote: >>> On 04/24/18 09:19, Jan Kiszka wrote: >>>> Only the overlay notifier callbacks have a chance to potentially get >>>> hold of references to those two resources, but they do not store them. >>>> So it is safe to stop the intentional leaking. >>>> >>>> See also https://lkml.org/lkml/2018/4/23/1063 and following. >>>> >>>> Signed-off-by: Jan Kiszka >>>> --- >>>> >>>> Ideally, we sort out any remaining worries during the 4.17-rc cycle. >>>> >>>> drivers/of/overlay.c | 13 ++----------- >>>> 1 file changed, 2 insertions(+), 11 deletions(-) >>>> >>>> diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c >>>> index b35fe88f1851..3553f1f57a62 100644 >>>> --- a/drivers/of/overlay.c >>>> +++ b/drivers/of/overlay.c >>>> @@ -671,17 +671,8 @@ static void free_overlay_changeset(struct overlay_changeset *ovcs) >>>> of_node_put(ovcs->fragments[i].overlay); >>>> } >>>> kfree(ovcs->fragments); >>>> - >>>> - /* >>>> - * TODO >>>> - * >>>> - * would like to: kfree(ovcs->overlay_tree); >>>> - * but can not since drivers may have pointers into this data >>>> - * >>>> - * would like to: kfree(ovcs->fdt); >>>> - * but can not since drivers may have pointers into this data >>>> - */ >>>> - >>>> + kfree(ovcs->overlay_tree); >>>> + kfree(ovcs->fdt); >>>> kfree(ovcs); >>>> } >>>> >>>> >>> >>> Nack. It is premature to submit this while the conversation is >>> continuing in the other thread. >>> >>> I'll continue the conversation in the other thread. >>> >> >> Well, at least the strongest argument has been resolved now, the >> notifier topic. Curious to learn what remains. As I noted, we should >> work hard to sort out the API regression prior to the release. > > Nope, the notifier discussion continues in the other thread. Thanks for your patience in the other thread. As I noted there, I am now willing to accept this patch with some small changes. Please add a minimal section to Documentation/devicetree/overlay-notes.txt about overlay notifiers. The most important thing to note there is that the overlay notifiers are not allowed to retain any pointers into the overlay devicetree. Also, instead of removing the "TODO" comment in free_overlay_changeset(), change it to say something to the effect of "there should be no live pointers into ovcs->overlay_tree and ovcs->fdt due to the policy that overlay notifiers are not allowed to retain pointers into the overlay devicetree". I will also add myself to the OPEN FIRMWARE AND DEVICE TREE OVERLAYS entry of MAINTAINERS and add a keyword line to catch overlay notifiers. I am not happy about freeing the overlay devicetree and overlay fdt while overlay notifiers are able to retain pointers into the overlay devicetree and overlay fdt, but am willing to accept documentation and review as a partial protection until the devicetree access APIs can be modified to prevent the notifiers from accessing the pointers. The volume of overlay notifier patches should be small enough to not be a review burden. -Frank