Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp374413pxk; Fri, 11 Sep 2020 09:12:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlO02nfzem9ac5/e/8oPMAeZz8US3jUgIN3sprQRPnM7u8ex+6MAKXmQvfai5eK4KhDCgW X-Received: by 2002:a17:906:cb98:: with SMTP id mf24mr2902821ejb.90.1599840778329; Fri, 11 Sep 2020 09:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599840778; cv=none; d=google.com; s=arc-20160816; b=dMYUt4M3xyiNHvOsifaFxblsOcLQtKYL1qDr1ePshw7uhBrrsp/qdoKkfviTaVls3r LWysqs7YNIr4w3OQSZXbJLqQGwkh5goK+k8D8Zxs602zV8HaroXaEbpHSq5oPxjCRV2f AVmMiAElf64KYn/RGbySMG/bXepv5LCBTCTPB2UXRf0V2yF25fm+Qzy04yw+sNttAR4r egc9cMe5fNstxJFKOzXw3V9IF727oBWcuWa9K5a4dnWx1hx6+FV3eQ9vkoqz2s/QX3Bp 6f6gIN+1S8OCMu0VALTT67Rgwo/J1kO32fI1rDkX7mOxZ4inYflFtHbyDzKRCGOXm8Wp WyQA== 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:autocrypt:from:references:cc:to:subject:reply-to; bh=AYPCMVE5+4lz80oAd0FTlLTpG9wKp/CHym7+dOireu0=; b=jbz6LbEH7oZHApzdnRKQUOpVqGYpP2o+Bv9fY3pUqU7Q6vXhSyA6jI32ZZIm9qcL1z FASawR+YKE/ju3MlvvuitVcjjEWg+sPmnPuItdMjAC/1SFXxH0MN1lIU6y4TIbrUU00G Jt9kJSQ3seHVFXMb47wO2ja7my4t/7i55oaJgp0eoexu8tYkB3NVLubZj6cv0IEmPmP+ YFBMRUoGHlx/2FcA0gFtYKLouWfcDsvihjKU8YK/+rnaQr6f4MtcvFNxOU8cUbaMFHqb nPCQ5gWL5pjjjmt8dlqdLnmsbGmcFrKciucUufDfUxN1gor/ymDdozVjSausITLR7iE2 m2LA== 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 c15si1581274ejr.34.2020.09.11.09.12.35; Fri, 11 Sep 2020 09:12:58 -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 S1726631AbgIKQJB (ORCPT + 99 others); Fri, 11 Sep 2020 12:09:01 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:38160 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbgIKQIm (ORCPT ); Fri, 11 Sep 2020 12:08:42 -0400 Received: by mail-lj1-f196.google.com with SMTP id w3so12884284ljo.5 for ; Fri, 11 Sep 2020 09:08:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=AYPCMVE5+4lz80oAd0FTlLTpG9wKp/CHym7+dOireu0=; b=n2opaqsRb0z7l0lbcyGwr/ZXVQUkeciY0oYiC/HJBhZEKx/Fly/4mvf/AglSCk/vRW npjKHaWRcQFZdJzNIsTH2rOKl/TxMMzqKV7kKeKDZZj1mhWshqUk+w/wIF0X67uQpDfc 8iymVN/l47pRXREfMEQdnxeydvkNsrj/j5thpAsZ5N/Blk6kika8xopGM45+VQMamFaM cCpRbC9kCQFLRmOKCiWvps1Sil9coOLuFr17gv1rZ64V28pR2gO72XcRJHVckO6QnyYC gzXxoNbvWbP5aoosVbBLKDh79OCQ81LMVverX90X03AfRW5IIhMLpZDc/sQAY2sAJuEx kbmA== X-Gm-Message-State: AOAM5303TOsHoksUhoXXOXKGQLGxjs9UlLHWYCCSulEeqpsr4bFQIBk0 +xTwgjcFhnSDyfpISWV1hWPGew77D0s= X-Received: by 2002:a2e:9d8a:: with SMTP id c10mr1154536ljj.83.1599840518400; Fri, 11 Sep 2020 09:08:38 -0700 (PDT) Received: from [10.68.32.147] (broadband-37-110-38-130.ip.moscow.rt.ru. [37.110.38.130]) by smtp.gmail.com with ESMTPSA id t1sm576862ljt.21.2020.09.11.09.08.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Sep 2020 09:08:37 -0700 (PDT) Reply-To: efremov@linux.com Subject: Re: [PATCH] scripts: kzfree.cocci: Deprecate use of kzfree To: Alex Dewar , Julia Lawall Cc: Gilles Muller , Nicolas Palix , Michal Marek , Mauro Carvalho Chehab , Alexandre Belloni , Jonathan Corbet , cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org References: <20200911134956.60910-1-alex.dewar90@gmail.com> From: Denis Efremov Autocrypt: addr=efremov@linux.com; keydata= mQINBFsJUXwBEADDnzbOGE/X5ZdHqpK/kNmR7AY39b/rR+2Wm/VbQHV+jpGk8ZL07iOWnVe1 ZInSp3Ze+scB4ZK+y48z0YDvKUU3L85Nb31UASB2bgWIV+8tmW4kV8a2PosqIc4wp4/Qa2A/ Ip6q+bWurxOOjyJkfzt51p6Th4FTUsuoxINKRMjHrs/0y5oEc7Wt/1qk2ljmnSocg3fMxo8+ y6IxmXt5tYvt+FfBqx/1XwXuOSd0WOku+/jscYmBPwyrLdk/pMSnnld6a2Fp1zxWIKz+4VJm QEIlC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e7v zod9dwxYdGXnNRlW+YOCdFNVPMvPDr08zgzXaZ2+QJjp44HSyzxgONmHAroFcqCFUlfAqUDO T30gV5bQ8BHqvfWyEhJT+CS3JJyP8BmmSgPa0Adlp6Do+pRsOO1YNNO78SYABhMi3fEa7X37 WxL31TrNCPnIauTgZtf/KCFQJpKaakC3ffEkPhyTjEl7oOE9xccNjccZraadi+2uHV0ULA1m ycHhb817A03n1I00QwLf2wOkckdqTqRbFFI/ik69hF9hemK/BmAHpShI+z1JsYT9cSs8D7wb aF/jQVy4URensgAPkgXsRiboqOj/rTz9F5mpd/gPU/IOUPFEMoo4TInt/+dEVECHioU3RRrW EahrGMfRngbdp/mKs9aBR56ECMfFFUPyI3VJsNbgpcIJjV/0N+JdJKQpJ/4uQ2zNm0wH/RU8 CRJvEwtKemX6fp/zLI36Gvz8zJIjSBIEqCb7vdgvWarksrhmi6/Jay5zRZ03+k6YwiqgX8t7 ANwvYa1h1dQ36OiTqm1cIxRCGl4wrypOVGx3OjCar7sBLD+NkwO4RaqFvdv0xuuy4x01VnOF Message-ID: <1486f777-23d9-19c4-d26d-bba1d8704660@linux.com> Date: Fri, 11 Sep 2020 19:08:37 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200911134956.60910-1-alex.dewar90@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 Hi, same patch https://lkml.org/lkml/2020/8/11/130 Julia, I've send all the patches to fix existing kfree_sensitive/kvfree_sensitive reports. https://lkml.org/lkml/2020/8/27/168 https://lkml.org/lkml/2020/8/27/93 Thanks, Denis On 9/11/20 4:49 PM, Alex Dewar wrote: > kzfree() is effectively deprecated as of commit 453431a54934 ("mm, > treewide: rename kzfree() to kfree_sensitive()"). It is currently just a > legacy alias for kfree_sensitive(), which achieves the same thing. > > Update kzfree.cocci accordingly: > 1) Replace instances of kzfree with kfree_sensitive > 2) Merge different rules for memset/memset_explicit as kzfree and > kfree_sensitive are now equivalent > 3) Rename script to kfree_sensitive.cocci > > In addition: > 4) Move the script to the free/ subfolder, where it would seem to fit > better > > Signed-off-by: Alex Dewar > --- > .../kfree_sensitive.cocci} | 38 +++++-------------- > 1 file changed, 10 insertions(+), 28 deletions(-) > rename scripts/coccinelle/{api/kzfree.cocci => free/kfree_sensitive.cocci} (59%) > > diff --git a/scripts/coccinelle/api/kzfree.cocci b/scripts/coccinelle/free/kfree_sensitive.cocci > similarity index 59% > rename from scripts/coccinelle/api/kzfree.cocci > rename to scripts/coccinelle/free/kfree_sensitive.cocci > index 33625bd7cec9..a87f93f2ed5c 100644 > --- a/scripts/coccinelle/api/kzfree.cocci > +++ b/scripts/coccinelle/free/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 k{,v}free_sensitive rather than memset or memzero_explicit followed by > +/// k{,v}free > /// > // 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,7 @@ 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}) > @@ -53,34 +53,16 @@ position m != cond.ok; > 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); > -//| > -- \(vfree\|kvfree\)(E)@p; > -+ kvfree_sensitive(E, size); > -//) > - > -@rp_memset depends on patch@ > -expression E, size; > -position p : script:python() { relevant(p) }; > -position m != cond.ok; > -type T; > -@@ > - > +| > - memset@m((T)E, 0, size); > +) > ... when != E > when strict > ( > - kfree(E)@p; > -+ kzfree(E); > ++ kfree_sensitive(E); > | > - \(vfree\|kvfree\)(E)@p; > + kvfree_sensitive(E, size); > @@ -91,11 +73,11 @@ p << r.p; > @@ > > coccilib.report.print_report(p[0], > - "WARNING: opportunity for kzfree/kvfree_sensitive") > + "WARNING: opportunity for k{,v}free_sensitive") > > @script:python depends on org@ > p << r.p; > @@ > > coccilib.org.print_todo(p[0], > - "WARNING: opportunity for kzfree/kvfree_sensitive") > + "WARNING: opportunity for k{,v}free_sensitive") >