Received: by 10.192.165.148 with SMTP id m20csp1699338imm; Thu, 26 Apr 2018 00:33:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx49sfvIVkEjkVppGq4XGVt322UE0ZaiQPp6m40A4nPlZ21+LQZkv4vW+vesR96/oeTnNBZPX X-Received: by 2002:a17:902:a50d:: with SMTP id s13-v6mr32090654plq.228.1524728002709; Thu, 26 Apr 2018 00:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524728002; cv=none; d=google.com; s=arc-20160816; b=dCIt++gw3zz3UTDnDyUWaz+lLD/SfjqkYlkYMKI9L3VtGUg62xiwAlgMUUah40geUJ pwV9V9dTN6pRM94Wd7yY4MAhCUJYlZbu+04luwV2pH3+7CPS//0Us2NVvF44bHytHNNo A4nV/VPW/T1GLwcXHm7MdKdFYASqALGEqVwoQGFg175Gu6BaTtPnKVhlW5m5wP7oHqtl TCYzkdNThwUYOw4ZTehr0sFxtrbkHPqIq01EfyV2NP7JwFvA322x6JRglbVAujaL90UB EKNt5CJZeXUXKUC62LdEzlpNaknKJZ8k8aE0j6QXmsJEGyohUoA9rC2cy3fYc3j50pIw 1SAg== 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:openpgp:from:references:cc:to:subject :arc-authentication-results; bh=TmgcoWoUXonMAV2s3/jvR4T+4eMTo8YQ6xo9OV5ZSfM=; b=HnIwRMezZkA34VmtnzAUnb51oOrygpp+RHKOa+kEUpV2IcyD83cYnVVM7NMHTj0YYZ IXIGjEmItrKLXiQu1U/Q3nz70xnqWdY7XSLQJkI8z3bDLoxBu0ZfHZNRMyX9zXXcXfvD XurUbfjWqzH9ewFlNr0tKZkccBh+tC6nXiIIMBLuiuPIHBcHmBfv1qUUYV3ATOnBdCEg M0vUjc43xMRMymDbbAzDCvGnuImxHEo4b1k+8DwPe/Kgx+usQ1u+/XolnGubAZNKqkp/ lH7lhCk9dDBNoC0lkM2u7YnE0v7IWGiAkwexsHynmEZtwtYdzNJOnz61UTtLbsAnqyMb loFg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3-v6si6414275plh.224.2018.04.26.00.33.08; Thu, 26 Apr 2018 00:33:22 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753424AbeDZHcD (ORCPT + 99 others); Thu, 26 Apr 2018 03:32:03 -0400 Received: from david.siemens.de ([192.35.17.14]:43763 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751465AbeDZHcA (ORCPT ); Thu, 26 Apr 2018 03:32:00 -0400 Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w3Q7VtG1023135 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Apr 2018 09:31:55 +0200 Received: from [167.87.44.129] ([167.87.44.129]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id w3Q7VsVs020826; Thu, 26 Apr 2018 09:31:54 +0200 Subject: Re: [PATCH] of: overlay: Stop leaking resources on overlay removal To: Frank Rowand , 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> <17561711-94f7-b3d4-8f06-9cfa69daaf23@gmail.com> <033fba6b-d93c-249c-d552-1f5336b34387@gmail.com> From: Jan Kiszka Openpgp: preference=signencrypt Message-ID: <46dbbff8-79ee-d397-7f8e-791fb1bc594c@siemens.com> Date: Thu, 26 Apr 2018 09:31:54 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: <033fba6b-d93c-249c-d552-1f5336b34387@gmail.com> 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 On 2018-04-26 02:44, Frank Rowand wrote: > On 04/25/18 17:32, Frank Rowand wrote: >> 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. > > Please also add a function header comment to of_overlay_notifier_register() > in drivers/of/overlay.c that notes the restriction on the overlay notifier. > > >> 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 >> >> > Thanks for reconsidering! I'll look into your change requests soon and come up with v2. Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux