Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1020151pxk; Sat, 12 Sep 2020 08:10:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsPYPhJ+io6SppFddlZof5lKl8OUudWionzipaQV4fpr+gFsNWMDcxwYykHf8iBIyGH9EJ X-Received: by 2002:a17:906:fccb:: with SMTP id qx11mr6553223ejb.429.1599923454947; Sat, 12 Sep 2020 08:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599923454; cv=none; d=google.com; s=arc-20160816; b=WwZd8Cn7oNfve6EfQUzUs0rc++uO0AIz1BLvnP3bmMWdUMOSWu3rE+gec5FdWvi9dT xyB9qGaIi8tVjJ+FERdoA5Ot3NxyJRwpHKN5KyiUrKYkt3Md1OelYYl/jvMZgbhRL8oj b7nVJvoloO4YbqsfiIOAj7Hs+iJzzOkO4nvLnvco8o8mP0hNS3Rw9CFRcQX5PJWaM8bc DjhymWvMMNtwFw+QaiIRNCxswUKFXQw7oUA59BTHEkkz6zOObyxvzjvJOkSAcq5fBJpL hO/ZXTKEws4kUnDtnhPxRy9VeoArWJxqRjH75Y5Dvfhg2g4uPnXnoUs81FUhTUXqaQDg Svsg== 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=o9BoFaCrl+MqnWB4Akl/9z3QcUx7NCMTSZBlXQ/v94g=; b=cxFoEQJCf7dgo9yJxm+mUzdPEcWXTQNP4/SIU0NzfxkercwfyW086LvTnTm50rLd7U P6gXite/qT7IPhQ0wy+VEH32SEJbVMtHqBOqVOXugpP2N5uOueJShPLcAtEsyJGNVOzw FHzn1hFjc+DIjy30Qd5cDbWSa5sk9FIgXtvF3LM2zKNsPwSsTSBKJiS26qmIVstUc75d XH2Sskp20vkIT0B71myTbVREeZ74iWgO9FQtznjeVnnp2BiYpBXg/ZWXVYTsj9340vUd a8E++1uhX9/zs8hKcgZZXJLADKknKiBxWOka5OFMLPpcm/ulpjZKoISHFeHz+bVkHdau XN3g== 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 h7si3335744ejt.170.2020.09.12.08.10.31; Sat, 12 Sep 2020 08:10:54 -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 S1725876AbgILPIf (ORCPT + 99 others); Sat, 12 Sep 2020 11:08:35 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:22313 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725850AbgILPIX (ORCPT ); Sat, 12 Sep 2020 11:08:23 -0400 X-IronPort-AV: E=Sophos;i="5.76,359,1592863200"; d="scan'208";a="467361552" Received: from abo-173-121-68.mrs.modulonet.fr (HELO hadrien) ([85.68.121.173]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Sep 2020 17:08:19 +0200 Date: Sat, 12 Sep 2020 17:08:19 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Denis Efremov cc: Julia Lawall , cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org, Eric Biggers , alex.dewar90@gmail.com, alexandre.belloni@bootlin.com, corbet@lwn.net, mchehab+huawei@kernel.org Subject: Re: [PATCH] coccinelle: api: update kzfree script to kfree_sensitive In-Reply-To: <20200811074953.73994-1-efremov@linux.com> Message-ID: References: <20200604140805.111613-1-efremov@linux.com> <20200811074953.73994-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 Tue, 11 Aug 2020, Denis Efremov wrote: > Commit 453431a54934 ("mm, treewide: rename kzfree() to kfree_sensitive()") > renames kzfree to kfree_sensitive and uses memzero_explicit(...) instead of > memset(..., 0, ...) internally. Update cocci script to reflect these > changes. > > Signed-off-by: Denis Efremov Applied, thanks. > --- > Julia, I think you can squash this commit with original script, or I can > resend the whole script since it's not merged to the mainline. > > .../{kzfree.cocci => kfree_sensitive.cocci} | 29 +++++++++---------- > 1 file changed, 13 insertions(+), 16 deletions(-) > rename scripts/coccinelle/api/{kzfree.cocci => kfree_sensitive.cocci} (70%) > > diff --git a/scripts/coccinelle/api/kzfree.cocci b/scripts/coccinelle/api/kfree_sensitive.cocci > similarity index 70% > rename from scripts/coccinelle/api/kzfree.cocci > rename to scripts/coccinelle/api/kfree_sensitive.cocci > index 33625bd7cec9..e4a066a0b77d 100644 > --- a/scripts/coccinelle/api/kzfree.cocci > +++ b/scripts/coccinelle/api/kfree_sensitive.cocci > @@ -1,13 +1,13 @@ > // SPDX-License-Identifier: GPL-2.0-only > /// > -/// Use kzfree, kvfree_sensitive rather than memset or > -/// memzero_explicit followed by kfree > +/// Use kfree_sensitive, kvfree_sensitive rather than memset or > +/// memzero_explicit followed by kfree. > /// > // Confidence: High > // Copyright: (C) 2020 Denis Efremov ISPRAS > // Options: --no-includes --include-headers > // > -// Keywords: kzfree, kvfree_sensitive > +// Keywords: kfree_sensitive, kvfree_sensitive > // > > virtual context > @@ -18,7 +18,8 @@ virtual report > @initialize:python@ > @@ > # kmalloc_oob_in_memset uses memset to explicitly trigger out-of-bounds access > -filter = frozenset(['kmalloc_oob_in_memset', 'kzfree', 'kvfree_sensitive']) > +filter = frozenset(['kmalloc_oob_in_memset', > + 'kfree_sensitive', 'kvfree_sensitive']) > > def relevant(p): > return not (filter & {el.current_element for el in p}) > @@ -56,17 +57,13 @@ type T; > - memzero_explicit@m((T)E, size); > ... when != E > when strict > -// TODO: uncomment when kfree_sensitive will be merged. > -// Only this case is commented out because developers > -// may not like patches like this since kzfree uses memset > -// internally (not memzero_explicit). > -//( > -//- kfree(E)@p; > -//+ kfree_sensitive(E); > -//| > +( > +- kfree(E)@p; > ++ kfree_sensitive(E); > +| > - \(vfree\|kvfree\)(E)@p; > + kvfree_sensitive(E, size); > -//) > +) > > @rp_memset depends on patch@ > expression E, size; > @@ -80,7 +77,7 @@ type T; > when strict > ( > - kfree(E)@p; > -+ kzfree(E); > ++ kfree_sensitive(E); > | > - \(vfree\|kvfree\)(E)@p; > + kvfree_sensitive(E, size); > @@ -91,11 +88,11 @@ p << r.p; > @@ > > coccilib.report.print_report(p[0], > - "WARNING: opportunity for kzfree/kvfree_sensitive") > + "WARNING: opportunity for kfree_sensitive/kvfree_sensitive") > > @script:python depends on org@ > p << r.p; > @@ > > coccilib.org.print_todo(p[0], > - "WARNING: opportunity for kzfree/kvfree_sensitive") > + "WARNING: opportunity for kfree_sensitive/kvfree_sensitive") > -- > 2.26.2 > >