From: "Tobin C. Harding" <me@tobin.cc>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Tobin C. Harding" <me@tobin.cc>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Theodore Ts'o <tytso@mit.edu>, Kees Cook <keescook@chromium.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Tycho Andersen <tycho@docker.com>,
"Roberts, William C" <william.c.roberts@intel.com>,
Tejun Heo <tj@kernel.org>,
Jordan Glover <Golden_Miller83@protonmail.ch>,
Greg KH <gregkh@linuxfoundation.org>,
Petr Mladek <pmladek@suse.com>, Joe Perches <joe@perches.com>,
Ian Campbell <ijc@hellion.org.uk>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <wil.deacon@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Chris Fries <cfries@google.com>,
Dave Weinstein <olorin@google.com>,
Daniel Micay <danielmicay@gmail.com>,
Subject: [PATCH v2 7/8] scripts/leaking_addresses: add support for ppc64
Date: Thu, 9 Nov 2017 16:09:34 +1100 [thread overview]
Message-ID: <1510204175-10138-8-git-send-email-me@tobin.cc> (raw)
In-Reply-To: <1510204175-10138-1-git-send-email-me@tobin.cc>
Currently script is targeted at x86_64. We can support other
architectures by using the correct regular expressions for each
architecture.
Add the infrastructure to support multiple architectures. Add support
for ppc64.
Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
scripts/leaking_addresses.pl | 66 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 60 insertions(+), 6 deletions(-)
diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
index 4610ad3c80c2..1d6ab7f1b10c 100755
--- a/scripts/leaking_addresses.pl
+++ b/scripts/leaking_addresses.pl
@@ -21,6 +21,7 @@ use File::Spec;
use Cwd 'abs_path';
use Term::ANSIColor qw(:constants);
use Getopt::Long qw(:config no_auto_abbrev);
+use Config;
my $P = $0;
my $V = '0.01';
@@ -28,6 +29,11 @@ my $V = '0.01';
# Directories to scan.
my @DIRS = ('/proc', '/sys');
+# Script can only grep for kernel addresses on the following architectures. If
+# your architecture is not listed here and has a grep'able kernel address please
+# consider submitting a patch.
+my @SUPPORTED_ARCHITECTURES = ('x86_64', 'ppc64');
+
# Command line options.
my $help = 0;
my $debug = 0;
@@ -137,6 +143,20 @@ if (!$input_raw and ($squash_by_path or $squash_by_filename)) {
exit(128);
}
+if (!is_supported_architecture()) {
+ printf "\nScript does not support your architecture, sorry.\n";
+ printf "\nCurrently we support: \n\n";
+ foreach(@SUPPORTED_ARCHITECTURES) {
+ printf "\t%s\n", $_;
+ }
+
+ my $archname = $Config{archname};
+ printf "\n\$ perl -MConfig -e \'print \"\$Config{archname}\\n\"\'\n";
+ printf "%s\n", $archname;
+
+ exit(129);
+}
+
if ($output_raw) {
open my $fh, '>', $output_raw or die "$0: $output_raw: $!\n";
select $fh;
@@ -152,6 +172,31 @@ sub dprint
printf(STDERR @_) if $debug;
}
+sub is_supported_architecture
+{
+ return (is_x86_64() or is_ppc64());
+}
+
+sub is_x86_64
+{
+ my $archname = $Config{archname};
+
+ if ($archname =~ m/x86_64/) {
+ return 1;
+ }
+ return 0;
+}
+
+sub is_ppc64
+{
+ my $archname = $Config{archname};
+
+ if ($archname =~ m/powerpc/ and $archname =~ m/64/) {
+ return 1;
+ }
+ return 0;
+}
+
sub is_false_positive
{
my ($match) = @_;
@@ -161,10 +206,12 @@ sub is_false_positive
return 1;
}
-
- if ($match =~ '\bf{10}600000\b' or# vsyscall memory region, we should probably check against a range here.
- $match =~ '\bf{10}601000\b') {
- return 1;
+ if (is_x86_64) {
+ # vsyscall memory region, we should probably check against a range here.
+ if ($match =~ '\bf{10}600000\b' or
+ $match =~ '\bf{10}601000\b') {
+ return 1;
+ }
}
return 0;
@@ -174,7 +221,7 @@ sub is_false_positive
sub may_leak_address
{
my ($line) = @_;
- my $address = '\b(0x)?ffff[[:xdigit:]]{12}\b';
+ my $address_re;
# Signal masks.
if ($line =~ '^SigBlk:' or
@@ -187,7 +234,14 @@ sub may_leak_address
return 0;
}
- while (/($address)/g) {
+ # One of these is guaranteed to be true.
+ if (is_x86_64()) {
+ $address_re = '\b(0x)?ffff[[:xdigit:]]{12}\b';
+ } elsif (is_ppc64()) {
+ $address_re = '\b(0x)?[89abcdef]00[[:xdigit:]]{13}\b';
+ }
+
+ while (/($address_re)/g) {
if (!is_false_positive($1)) {
return 1;
}
--
2.7.4
next prev parent reply other threads:[~2017-11-09 5:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-09 5:09 [PATCH v2 0/8] scripts/leaking_addresses: add summary reporting Tobin C. Harding
2017-11-09 5:09 ` [PATCH v2 1/8] scripts/leaking_addresses: use tabs not spaces Tobin C. Harding
2017-11-09 5:09 ` [PATCH v2 2/8] scripts/leaking_addresses: remove dead code Tobin C. Harding
2017-11-09 5:09 ` [PATCH v2 3/8] scripts/leaking_addresses: remove command line options Tobin C. Harding
2017-11-09 5:09 ` [PATCH v2 4/8] scripts/leaking_addresses: fix comment typo Tobin C. Harding
2017-11-09 5:09 ` [PATCH v2 5/8] scripts/leaking_addresses: add to exclude files/paths Tobin C. Harding
2017-11-09 5:09 ` [PATCH v2 6/8] scripts/leaking_addresses: add summary reporting Tobin C. Harding
2017-11-09 5:09 ` Tobin C. Harding [this message]
2017-11-09 5:09 ` [PATCH v2 8/8] scripts/leaking_addresses: add timeout on file read 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=1510204175-10138-8-git-send-email-me@tobin.cc \
--to=me@tobin.cc \
--cc=Golden_Miller83@protonmail.ch \
--cc=Jason@zx2c4.com \
--cc=catalin.marinas@arm.com \
--cc=cfries@google.com \
--cc=danielmicay@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=ijc@hellion.org.uk \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=olorin@google.com \
--cc=pbonzini@redhat.com \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tycho@docker.com \
--cc=tytso@mit.edu \
--cc=wil.deacon@arm.com \
--cc=william.c.roberts@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).