aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobin C. Harding <me@tobin.cc>2017-12-06 20:33:21 -0500
committerTobin C. Harding <me@tobin.cc>2018-04-06 18:50:34 -0400
commit87e37588563da905a8506b8922cfba1d71382a64 (patch)
treeedbbc7102182bdfb4d0494b0d9dea81d54a5f106
parent15d60a35b8fe82363325494a2a7c49f26f9f5594 (diff)
leaking_addresses: add range check for vsyscall memory
Currently script checks only first and last address in the vsyscall memory range. We can do better than this. When checking for false positives against $match, we can convert $match to a hexadecimal value then check if it lies within the range of vsyscall addresses. Check whole range of vsyscall addresses when checking for false positive. Signed-off-by: Tobin C. Harding <me@tobin.cc>
-rwxr-xr-xscripts/leaking_addresses.pl20
1 files changed, 14 insertions, 6 deletions
diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
index 31cf54ad379f..398e534f0e16 100755
--- a/scripts/leaking_addresses.pl
+++ b/scripts/leaking_addresses.pl
@@ -19,6 +19,7 @@ use Cwd 'abs_path';
19use Term::ANSIColor qw(:constants); 19use 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/;
22 23
23my $P = $0; 24my $P = $0;
24my $V = '0.01'; 25my $V = '0.01';
@@ -195,17 +196,24 @@ sub is_false_positive
195 return 1; 196 return 1;
196 } 197 }
197 198
198 if (is_x86_64()) { 199 if (is_x86_64() and is_in_vsyscall_memory_region($match)) {
199 # vsyscall memory region, we should probably check against a range here. 200 return 1;
200 if ($match =~ '\bf{10}600000\b' or
201 $match =~ '\bf{10}601000\b') {
202 return 1;
203 }
204 } 201 }
205 202
206 return 0; 203 return 0;
207} 204}
208 205
206sub is_in_vsyscall_memory_region
207{
208 my ($match) = @_;
209
210 my $hex = hex($match);
211 my $region_min = hex("0xffffffffff600000");
212 my $region_max = hex("0xffffffffff601000");
213
214 return ($hex >= $region_min and $hex <= $region_max);
215}
216
209# True if argument potentially contains a kernel address. 217# True if argument potentially contains a kernel address.
210sub may_leak_address 218sub may_leak_address
211{ 219{