Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp221067pxa; Tue, 11 Aug 2020 00:51:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPF7+LolMzchwYoRHoS2Dy4C59Hf5RGPtw3b3yGODBO7BlALlNP+JmwKM6Aa5C68usi1Fe X-Received: by 2002:aa7:c34d:: with SMTP id j13mr24702788edr.209.1597132318365; Tue, 11 Aug 2020 00:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597132318; cv=none; d=google.com; s=arc-20160816; b=ONwrP3mxClZ30qbmFNTYQ5n016WytX8K7EH1Plxnv84VCCRHI4AY9IId9g/WV1fube JA9p05LIjid+OI56TOEoAiqEkbUzqZs/ryE1tm/7nZbFz9o1MC7m4fnLjPZSw++7GTCx bckPvvibQ8SA5JcZsq/7UZgjWHno5t31QuP46vNV7IUdRt55EV+mCwsTVvrun51hcrhk +nwHF6LxfFO/LxjBr419R1lCBQZRODLKF1g1sdd3wLDLBRrzqkGfw3PVg4BWR5h5KSMD JsB//DjvbkGFT6ih2eKNS0FzL1xY8AhK/Nxk9/iRyKfbUvHKVEa6Sa/7Wy/rm023GE1x ZT2A== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7c9LgDQzwFBP2P6ArJr6sk6r1j+llzDsGb6lR6H9a1Q=; b=agf4k91jN9VZBwvfJLsj/B4sZarmm0eSBSktvABsMd6p/A/jZf2FWLti0jlEb8CggO KmB+KE1X59jGCmmSr+d3/s+TFsRVkqzm89o+28cXrE/OXGl91pJRMQMP+WGPzUx/zChv stAhJ3qh2mG17QKRrMlA6ATzGYlQ3ag56qiz8YGNpeneciIvM8Q24bichea9Gn93Ye7N rGlYDrSJOZ+tPqH+TF22Jpj3Lnm0mnJ0MWmgx+GvyDuhi5Sr5z3VhMSIiMn1LDXtW+Nn pAlc557E6THta89D5M0fZ/XPJV9zLFb4pVvWoonUf86PaFvb6f47NzDGvqsaVjmtaRvb iSsg== 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 e4si12060435ejr.98.2020.08.11.00.51.34; Tue, 11 Aug 2020 00:51: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 S1728275AbgHKHuF (ORCPT + 99 others); Tue, 11 Aug 2020 03:50:05 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45855 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728133AbgHKHuF (ORCPT ); Tue, 11 Aug 2020 03:50:05 -0400 Received: by mail-lf1-f66.google.com with SMTP id b30so6141339lfj.12 for ; Tue, 11 Aug 2020 00:50:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7c9LgDQzwFBP2P6ArJr6sk6r1j+llzDsGb6lR6H9a1Q=; b=DXuM86OYRLMp5V2HM3q+kYMPcCYCpGkmJaowe6sielCBa7OevbluIZ4X39LLHV/mbT /m3Lz8Wa3GdNQgKSuSrVbFj9dLDLhFxPCwZLMdrk8OOwLbM+v7MRIe/XXGFJ0qw0gZXV 7/XE3sriFbZGQ1E9WEXBJhEaXUChMT8hKNeJiFPjC6raWxHPJDXNMb4yEgg3ETVjYheB PGTMmKqswhAOZjYo9XLpFSCd8+fcPpskTSWcHZgAco1nFtDWG9wzygRyOUemiOqmUchp x3gUzzZNwSxPaLCcv7Pa7YNhjQjGyRSgVj2EX3yCBBTT95iQri0LlJPBLWclYRj4ITGR cNmg== X-Gm-Message-State: AOAM533hsniEGTI+MYbTqjsDKtqVckAiDN+kKid4G2pYlrhtW0BCeV6J oC+T8FEYBk0lYfmOF+dlkB/u0G9Z X-Received: by 2002:ac2:4542:: with SMTP id j2mr2586816lfm.110.1597132202193; Tue, 11 Aug 2020 00:50:02 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-38-130.ip.moscow.rt.ru. [37.110.38.130]) by smtp.googlemail.com with ESMTPSA id z25sm9918170ljz.13.2020.08.11.00.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 00:50:01 -0700 (PDT) From: Denis Efremov To: Julia Lawall Cc: Denis Efremov , cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org, Eric Biggers Subject: [PATCH] coccinelle: api: update kzfree script to kfree_sensitive Date: Tue, 11 Aug 2020 10:49:53 +0300 Message-Id: <20200811074953.73994-1-efremov@linux.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200604140805.111613-1-efremov@linux.com> References: <20200604140805.111613-1-efremov@linux.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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