From patchwork Mon Feb 19 02:50:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobin Harding X-Patchwork-Id: 10227047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7428E602B1 for ; Mon, 19 Feb 2018 02:51:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 675032886C for ; Mon, 19 Feb 2018 02:51:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BFBD2887B; Mon, 19 Feb 2018 02:51:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 572082886C for ; Mon, 19 Feb 2018 02:51:51 +0000 (UTC) Received: (qmail 3851 invoked by uid 550); 19 Feb 2018 02:51:26 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 3581 invoked from network); 19 Feb 2018 02:51:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=h2+HCMDIb0Oaw84/6 yEVQgh/amcpyPAymzZBUhaqT5U=; b=LVwOp7k+7R5Lqo7Bcruu+qToWvrmeLjiq 23GS16/VQZn+Mwf2BK3W90RVfXR11iTeGhJ+RMgWq8mkdL6T3YBQ+bbbptobNOFv p4LmgTnxdyghnANQdYr1yQ0IDuP0RfdmJ/jY9Cdp6dAcyqBZ+JLbaduwPl4kqR34 1Gfwd6lSqIvAnQXAP2om4SmbCimODB6WH2Ip7ZNgjdSnQGoIkaE3+Es2ifLVu1uW aYpLD7crKk8s2jXFMnRKczlpOPWeSfDMq8eVmrG2UXJwROJHDwCYnDI4r969XQc4 4fJaBG5Z2D5Dsm832EwAePvaJN/JNHJUZaImrwcFINFb2ZGb9dBVg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=h2+HCMDIb0Oaw84/6yEVQgh/amcpyPAymzZBUhaqT5U=; b=abrt51Xt DzwjrlwOvNZiqDSvL50IKtYNObJyU5GiihrUOZcWQqisC7GBr3kHzq/7kY3Y+1Wt Ri30BcamOa8Vmn8pk/LJLfb3xmOyYKT+nLNBLkfisFatcv7Yuj2bkyDWDzjDaGXT L3j3eZrVykxPwa7rQMO6Uz/nbOiOkSj5DF3jJgIz3Xp7zkc14DedmvO0hIcr+Bgv cr3bL6lsEHnYA0OtBmGeKuvt3ZHwaCxju3KCtfKjM7agDCpzzRNK5dWN6ydMHt8N cNj+abf3S/4z88UwjDCXwIWdpwK8ctj2NcuYlGFLk0iose3NCaK3evLWHJmHXl0i 1QHB0gj8FUWx9g== X-ME-Sender: From: "Tobin C. Harding" To: Kernel Hardening Cc: "Tobin C. Harding" , Tycho Andersen , LKML Subject: [PATCH 4/4] leaking_addresses: add scan_once array Date: Mon, 19 Feb 2018 13:50:49 +1100 Message-Id: <1519008649-15782-5-git-send-email-me@tobin.cc> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519008649-15782-1-git-send-email-me@tobin.cc> References: <1519008649-15782-1-git-send-email-me@tobin.cc> X-Virus-Scanned: ClamAV using ClamSMTP There are files under /proc that have the same format for each PID, e.g 'smaps'. We need only scan these files a single time to verify that they are not leaking addresses. This reduces the work the script must do. Add once_only array. Signed-off-by: Tobin C. Harding --- scripts/leaking_addresses.pl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl index f52e91ef7d5c..ab4e70d9efde 100755 --- a/scripts/leaking_addresses.pl +++ b/scripts/leaking_addresses.pl @@ -69,6 +69,12 @@ my @skip_any = ( 'fd', 'usbmon'); +# These files are the same format under each PID that they appear. +# We need only pass them once. +my @once_only = ( + 'smaps', + 'mb_groups'); + sub help { my ($exitcode) = @_; @@ -401,6 +407,25 @@ sub parse_dmesg close $cmd; } +sub already_scanned +{ + my ($filename) = @_; + state %seen; + + foreach (@once_only) { + if (/^$filename$/) { + if ($seen{$_} == 1) { + return 1; + } + $seen{$_} = 1; + + return 0; + } + } + + return 0; +} + # True if we should skip this path. sub skip { @@ -415,6 +440,10 @@ sub skip return 1 if (/^$filename$/); } + if (already_scanned($filename)) { + return 1; + } + return 0; }