Skip to content

Commit 3e389d4

Browse files
committed
leaking_addresses: Ignore input device status lines
These are false positives from the input subsystem: /proc/bus/input/devices: B: KEY=402000000 3803078f800d001 feffffdfffefffff fffffffffffffffe /sys/devices/platform/i8042/serio0/input/input1/uevent: KEY=402000000 3803078f800d001 feffffdfffefffff fffffffffffffffe /sys/devices/platform/i8042/serio0/input/input1/capabilities/key: 402000000 3803078f800d001 feffffdf Pass in the filename for more context and expand the "ignored pattern" matcher to notice these. Reviewed-by: Tycho Andersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 1b1bcbf commit 3e389d4

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

scripts/leaking_addresses.pl

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,10 @@ sub is_false_positive
284284
return is_false_positive_32bit($match);
285285
}
286286

287-
# 64 bit false positives.
288-
289-
if ($match =~ '\b(0x)?(f|F){16}\b' or
287+
# Ignore 64 bit false positives:
288+
# 0xfffffffffffffff[0-f]
289+
# 0x0000000000000000
290+
if ($match =~ '\b(0x)?(f|F){15}[0-9a-f]\b' or
290291
$match =~ '\b(0x)?0{16}\b') {
291292
return 1;
292293
}
@@ -303,7 +304,7 @@ sub is_false_positive_32bit
303304
my ($match) = @_;
304305
state $page_offset = get_page_offset();
305306

306-
if ($match =~ '\b(0x)?(f|F){8}\b') {
307+
if ($match =~ '\b(0x)?(f|F){7}[0-9a-f]\b') {
307308
return 1;
308309
}
309310

@@ -346,18 +347,23 @@ sub is_in_vsyscall_memory_region
346347
# True if argument potentially contains a kernel address.
347348
sub may_leak_address
348349
{
349-
my ($line) = @_;
350+
my ($path, $line) = @_;
350351
my $address_re;
351352

352-
# Signal masks.
353+
# Ignore Signal masks.
353354
if ($line =~ '^SigBlk:' or
354355
$line =~ '^SigIgn:' or
355356
$line =~ '^SigCgt:') {
356357
return 0;
357358
}
358359

359-
if ($line =~ '\bKEY=[[:xdigit:]]{14} [[:xdigit:]]{16} [[:xdigit:]]{16}\b' or
360-
$line =~ '\b[[:xdigit:]]{14} [[:xdigit:]]{16} [[:xdigit:]]{16}\b') {
360+
# Ignore input device reporting.
361+
# /proc/bus/input/devices: B: KEY=402000000 3803078f800d001 feffffdfffefffff fffffffffffffffe
362+
# /sys/devices/platform/i8042/serio0/input/input1/uevent: KEY=402000000 3803078f800d001 feffffdfffefffff fffffffffffffffe
363+
# /sys/devices/platform/i8042/serio0/input/input1/capabilities/key: 402000000 3803078f800d001 feffffdfffefffff fffffffffffffffe
364+
if ($line =~ '\bKEY=[[:xdigit:]]{9,14} [[:xdigit:]]{16} [[:xdigit:]]{16}\b' or
365+
($path =~ '\bkey$' and
366+
$line =~ '\b[[:xdigit:]]{9,14} [[:xdigit:]]{16} [[:xdigit:]]{16}\b')) {
361367
return 0;
362368
}
363369

@@ -400,7 +406,7 @@ sub parse_dmesg
400406
{
401407
open my $cmd, '-|', 'dmesg';
402408
while (<$cmd>) {
403-
if (may_leak_address($_)) {
409+
if (may_leak_address("dmesg", $_)) {
404410
print 'dmesg: ' . $_;
405411
}
406412
}
@@ -456,7 +462,7 @@ sub parse_file
456462
open my $fh, "<", $file or return;
457463
while ( <$fh> ) {
458464
chomp;
459-
if (may_leak_address($_)) {
465+
if (may_leak_address($file, $_)) {
460466
printf("$file: $_\n");
461467
}
462468
}
@@ -468,7 +474,7 @@ sub check_path_for_leaks
468474
{
469475
my ($path) = @_;
470476

471-
if (may_leak_address($path)) {
477+
if (may_leak_address($path, $path)) {
472478
printf("Path name may contain address: $path\n");
473479
}
474480
}

0 commit comments

Comments
 (0)