aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/leaking_addresses.pl32
1 files changed, 25 insertions, 7 deletions
diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
index b3ffbf8022ce..35d6dd9fdced 100755
--- a/scripts/leaking_addresses.pl
+++ b/scripts/leaking_addresses.pl
@@ -20,6 +20,7 @@ use Term::ANSIColor qw(:constants);
20use Getopt::Long qw(:config no_auto_abbrev); 20use Getopt::Long qw(:config no_auto_abbrev);
21use Config; 21use Config;
22use bigint qw/hex/; 22use bigint qw/hex/;
23use feature 'state';
23 24
24my $P = $0; 25my $P = $0;
25my $V = '0.01'; 26my $V = '0.01';
@@ -296,13 +297,7 @@ sub may_leak_address
296 return 0; 297 return 0;
297 } 298 }
298 299
299 # One of these is guaranteed to be true. 300 $address_re = get_address_re();
300 if (is_x86_64()) {
301 $address_re = '\b(0x)?ffff[[:xdigit:]]{12}\b';
302 } elsif (is_ppc64()) {
303 $address_re = '\b(0x)?[89abcdef]00[[:xdigit:]]{13}\b';
304 }
305
306 while (/($address_re)/g) { 301 while (/($address_re)/g) {
307 if (!is_false_positive($1)) { 302 if (!is_false_positive($1)) {
308 return 1; 303 return 1;
@@ -312,6 +307,29 @@ sub may_leak_address
312 return 0; 307 return 0;
313} 308}
314 309
310sub get_address_re
311{
312 if (is_x86_64()) {
313 return get_x86_64_re();
314 } elsif (is_ppc64()) {
315 return '\b(0x)?[89abcdef]00[[:xdigit:]]{13}\b';
316 }
317}
318
319sub get_x86_64_re
320{
321 # We handle page table levels but only if explicitly configured using
322 # CONFIG_PGTABLE_LEVELS. If config file parsing fails or config option
323 # is not found we default to using address regular expression suitable
324 # for 4 page table levels.
325 state $ptl = get_kernel_config_option('CONFIG_PGTABLE_LEVELS');
326
327 if ($ptl == 5) {
328 return '\b(0x)?ff[[:xdigit:]]{14}\b';
329 }
330 return '\b(0x)?ffff[[:xdigit:]]{12}\b';
331}
332
315sub parse_dmesg 333sub parse_dmesg
316{ 334{
317 open my $cmd, '-|', 'dmesg'; 335 open my $cmd, '-|', 'dmesg';