From patchwork Mon Feb 19 02:50:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobin Harding X-Patchwork-Id: 10227045 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 DB331602B1 for ; Mon, 19 Feb 2018 02:51:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE8912886C for ; Mon, 19 Feb 2018 02:51:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C34612887B; Mon, 19 Feb 2018 02:51:44 +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 E91F12886C for ; Mon, 19 Feb 2018 02:51:43 +0000 (UTC) Received: (qmail 3462 invoked by uid 550); 19 Feb 2018 02:51:20 -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 3345 invoked from network); 19 Feb 2018 02:51:19 -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=5LNGGAv5VmJ6N0ZiC 2ctlulzNBFN47Oc19TxF0btwk0=; b=YoI97MCkDqUdhoJntwK1prr1Ins+jP4F8 oN/9lHCfR3NtZkMgAMEr1n786ANQLFKtH2aDe9VqsOMUDb4t9G/4nJWjw3cV8chl 2zSJiVIi5LfjWoV1YXlYIDiDNITF9v03QNZXTQ2SLv9wZm4K+YYUCpWq9tg3Pznq 1ok3lZMizKEAAjnUN1LCTU8P/q7rLSKEYLK7bEULo9BUYZdhSIbfdCrmxXbIdZRD jXwIgeAZFKYFiOpeFVvEoxNCpYfBnMaJWrn5SErrgiTknKKJG5x9y7t1LGnMf1wz adLu9/o0u5EJHYXd1V9ytRe9T/FyEPCyL6P5Mv7hTQouiOvibNAoA== 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=5LNGGAv5VmJ6N0ZiC2ctlulzNBFN47Oc19TxF0btwk0=; b=P9jg7I5f LiiI6tI34m+9nn2bqhAaJyOPK7ly/1u5J+zPBCCUR89CdgBj4wBX9JGtln+PwKLk TRXGtO92l/7Z7eX4SxF1LSVosJ7+mn1rbIByjThkhw0WFy7Zl4tbIeFoGnXytk1m suqrRhvYcnxyfB9+lEzKN2NoGm+4SWr4OpsLPwvZ8ODVlOHMNnpQC2G8z4LLe6p2 MpNd2BD0kFp3Nvx9tdbXSPx98Mu8KUlRBJETQXnLzDLo4WLP7/Vam8pZfxMD+ZQo SX9Pg0QRtFIHeQWcWvgn0AHTgrkQu14sjvNv94LU4XquRXOKg6YiAkiEohpaVY+H /2hC5ENfwlRNTg== X-ME-Sender: From: "Tobin C. Harding" To: Kernel Hardening Cc: "Tobin C. Harding" , Tycho Andersen , LKML Subject: [PATCH 3/4] leaking_addresses: cache architecture name Date: Mon, 19 Feb 2018 13:50:48 +1100 Message-Id: <1519008649-15782-4-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 Currently we are repeatedly calling `uname -m`. This is causing the script to take a long time to run (more than 10 seconds to parse /proc/kallsyms). We can use Perl state variables to cache the result of the first call to `uname -m`. With this change in place the script scans the whole kernel in under a minute. Cache machine architecture in state variable. Signed-off-by: Tobin C. Harding --- scripts/leaking_addresses.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl index e7bf15a45a69..f52e91ef7d5c 100755 --- a/scripts/leaking_addresses.pl +++ b/scripts/leaking_addresses.pl @@ -175,7 +175,7 @@ sub is_32bit sub is_ix86_32 { - my $arch = `uname -m`; + state $arch = `uname -m`; chomp $arch; if ($arch =~ m/i[3456]86/) { @@ -198,12 +198,14 @@ sub is_arch sub is_x86_64 { - return is_arch('x86_64'); + state $is = is_arch('x86_64'); + return $is; } sub is_ppc64 { - return is_arch('ppc64'); + state $is = is_arch('ppc64'); + return $is; } # Gets config option value from kernel config file.