Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2012067pxa; Mon, 3 Aug 2020 05:21:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwraUZtP6zlRMGvxCDe4eg3lAtYcQZ3LjKS+8+4M4kPs9idEpzpHH6sOT0kWr9drBdQlbOw X-Received: by 2002:a17:906:5ad8:: with SMTP id x24mr15777096ejs.329.1596457277559; Mon, 03 Aug 2020 05:21:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596457277; cv=none; d=google.com; s=arc-20160816; b=dBlyksT7Rc4gbXHBctVnG8Ym1xIMi3GzO/XQpYjR3JyDT1xVDn5lUg6a2/kL/MSkbW CNyH0+RzaygbxDTmSvP6hSKt9soqYKdE6cykorUgrz2787ZFB0zVe9dcD2XxU21EY52i jh4S78uqYqEnBsxg+fUvjvYZ4NrMmhBj5PZBlH83t0pY3TxSZt5IQaclz7VAKAl2h8Uy B45Uhd9NhR2BQ6XFEAWvNdJJRq62UNr5HjMBgUY9cTUYEZbG2bCGi1UOmemlleVLWfNP 1uqDVuIbXaJYqslEWT/QzFmjgK6OSzazgeKitrpVqCOXvNByqtitHuRv48J9z+aEC7Ci sdVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=IukcTZ/xhbKy1B2brC/itRnRfJ5LytWKcjUZcr2CsYI=; b=e92K7cFJ92lplS3xjjZRNrkqCKNlKUCQ50WoScHd0BD8i171XyHFW22uIRue/M0kxz T3OktbPpaov4O4/8FFPB52BomXMihXhjb07QesLt9e+YZ0O+8ZXF0NmQLdZdEzxvCbj3 0yxLUmYg0HFGFiBEHa6FqZclI41bKIUGavOY9aXmCv6BkzBcvEpCnAs9AveBdmJ5MRWQ /Plex1gVG+lrOXgqAogDL5/fDNIEm/sCYkyTs7Sdx6NCYd3fxY6KMI7tNtsTEKyEJ64J iqTeTU17F+nwkHfkiD/kGv7/52/24/rP24w5GboJ1nWBCLuXufFzvipwSo+TeUgv3q1q iK8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z43si10093896ede.148.2020.08.03.05.20.55; Mon, 03 Aug 2020 05:21:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726725AbgHCMSH (ORCPT + 99 others); Mon, 3 Aug 2020 08:18:07 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:64325 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726189AbgHCMSF (ORCPT ); Mon, 3 Aug 2020 08:18:05 -0400 X-IronPort-AV: E=Sophos;i="5.75,430,1589234400"; d="scan'208";a="355857185" Received: from clt-128-93-177-162.vpn.inria.fr ([128.93.177.162]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Aug 2020 14:18:04 +0200 Date: Mon, 3 Aug 2020 14:18:03 +0200 (CEST) From: Julia Lawall X-X-Sender: julia@hadrien To: Denis Efremov cc: cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6] coccinelle: api: add kvfree script In-Reply-To: Message-ID: References: <20200605204237.85055-1-efremov@linux.com> <20200731210026.7186-1-efremov@linux.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 3 Aug 2020, Denis Efremov wrote: > > > On 8/2/20 11:24 PM, Julia Lawall wrote: > >> +@initialize:python@ > >> +@@ > >> +# low-level memory api > >> +filter = frozenset(['__vmalloc_area_node']) > >> + > >> +def relevant(p): > >> + return not (filter & {el.current_element for el in p}) > > > > Is this used? > > I'll remove it in v8. Or do you want me to add iterate_dir_item() in the list? What is that? > > > > > Otherwise, I think it would be good to not warn about a use of kvfree > > if that use is reachable from a kvmalloc. There seems to be such a false > > positive in fs/btrfs/send.c, on line 1118. > > I don't know how to handle this case without position filter. > It's too complex. In iterate_dir_item() there is: > buf = kmalloc(buf_len, GFP_KERNEL); > while(...) { > if (...) { > if (is_vmalloc_addr(buf)) { > vfree(buf); > ... > } else { > char *tmp = krealloc(buf, ...); > > if (!tmp) > kfree(buf); > ... > } > if (!buf) { > buf = kvmalloc(buf_len, GFP_KERNEL); > ... > } > } > } > kvfree(buf); > > Adding "when != kvfree(E)" is not enough: > * E = \(kvmalloc\|kvzalloc\|kvcalloc\|kvzalloc_node\|kvmalloc_node\| > * kvmalloc_array\)(...)@k > ... when != is_vmalloc_addr(E) > + when != kvfree(E) > when any > * \(kfree\|kzfree\|vfree\|vfree_atomic\)(E)@p Why not just @ok exists@ position p; expression E; @@ E = kvalloc(...) ... kvfree@p(...) Probably that is what you mean by a position filter, but why not add a position filter? julia > > > > It also seems that when there are both a kmalloc and a vmalloc, there is > > no warning if kfree or vfree is used. Is that intentional? > > > > No, I will try to address it in v8. > > Regards, > Denis >