From: "Tobin C. Harding" <me@tobin.cc>
To: Kernel Hardening <kernel-hardening@lists.openwall.com>
Cc: "Tobin C. Harding" <me@tobin.cc>, Tycho Andersen <tycho@tycho.ws>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 4/4] leaking_addresses: add scan_once array
Date: Mon, 19 Feb 2018 13:50:49 +1100 [thread overview]
Message-ID: <1519008649-15782-5-git-send-email-me@tobin.cc> (raw)
In-Reply-To: <1519008649-15782-1-git-send-email-me@tobin.cc>
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 <me@tobin.cc>
---
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;
}
--
2.7.4
next prev parent reply other threads:[~2018-02-19 2:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-19 2:50 [PATCH 0/4] leaking_addresses: simplify and optimize Tobin C. Harding
2018-02-19 2:50 ` [PATCH 1/4] leaking_addresses: do not parse binary files Tobin C. Harding
2018-02-19 2:50 ` [PATCH 2/4] leaking_addresses: simplify path skipping Tobin C. Harding
2018-02-26 1:26 ` Tycho Andersen
2018-02-26 2:00 ` Tobin C. Harding
2018-02-19 2:50 ` [PATCH 3/4] leaking_addresses: cache architecture name Tobin C. Harding
2018-02-19 2:50 ` Tobin C. Harding [this message]
2018-02-26 1:09 ` [PATCH 4/4] leaking_addresses: add scan_once array Tycho Andersen
2018-02-26 2:01 ` Tobin C. Harding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1519008649-15782-5-git-send-email-me@tobin.cc \
--to=me@tobin.cc \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tycho@tycho.ws \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®