mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] leaking_addresses: check path name for leaks
@ 2018-03-01 22:03 Tobin C. Harding
  2018-03-01 22:03 ` [PATCH 1/2] leaking_addresses: explicitly name variable used in regex Tobin C. Harding
  2018-03-01 22:03 ` [PATCH 2/2] leaking_addresses: check if file name contains address Tobin C. Harding
  0 siblings, 2 replies; 4+ messages in thread
From: Tobin C. Harding @ 2018-03-01 22:03 UTC (permalink / raw)
  To: Kernel Hardening; +Cc: Tobin C. Harding, Tycho Andersen, LKML

A couple more patches to the leaking_addresses.pl script.  First one is
refactor, does not change program logic.

Patch 2 adds a check on each path name as the scan traverses the
directory tree.  Suggested by Tycho.

thanks,
Tobin.

Tobin C. Harding (2):
  leaking_addresses: explicitly name variable used in regex
  leaking_addresses: check if file name contains address

 scripts/leaking_addresses.pl | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] leaking_addresses: explicitly name variable used in regex
  2018-03-01 22:03 [PATCH 0/2] leaking_addresses: check path name for leaks Tobin C. Harding
@ 2018-03-01 22:03 ` Tobin C. Harding
  2018-03-01 22:03 ` [PATCH 2/2] leaking_addresses: check if file name contains address Tobin C. Harding
  1 sibling, 0 replies; 4+ messages in thread
From: Tobin C. Harding @ 2018-03-01 22:03 UTC (permalink / raw)
  To: Kernel Hardening; +Cc: Tobin C. Harding, Tycho Andersen, LKML

Currently sub routine may_leak_address() is checking regex against Perl
special variable $_ which is _fortunately_ being set correctly in a loop
before this sub routine is called.  We already have declared a variable
to hold this value '$line' we should use it.

Use $line in regex match instead of implicit $_

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 scripts/leaking_addresses.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
index d5d31f3df97e..65a65aa64d26 100755
--- a/scripts/leaking_addresses.pl
+++ b/scripts/leaking_addresses.pl
@@ -363,7 +363,7 @@ sub may_leak_address
 	}
 
 	$address_re = get_address_re();
-	while (/($address_re)/g) {
+	while ($line =~ /($address_re)/g) {
 		if (!is_false_positive($1)) {
 			return 1;
 		}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] leaking_addresses: check if file name contains address
  2018-03-01 22:03 [PATCH 0/2] leaking_addresses: check path name for leaks Tobin C. Harding
  2018-03-01 22:03 ` [PATCH 1/2] leaking_addresses: explicitly name variable used in regex Tobin C. Harding
@ 2018-03-01 22:03 ` Tobin C. Harding
  2018-03-02  0:13   ` Tycho Andersen
  1 sibling, 1 reply; 4+ messages in thread
From: Tobin C. Harding @ 2018-03-01 22:03 UTC (permalink / raw)
  To: Kernel Hardening; +Cc: Tobin C. Harding, Tycho Andersen, LKML

Sometimes files may be created by using output from printk.  As the scan
traverses the directory tree we should parse each path name and check if
it is leaking an address.

Add check for leaking address on each path name.

Suggested-by: Tycho Andersen <tycho@tycho.ws>
Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 scripts/leaking_addresses.pl | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
index 65a65aa64d26..a550c9bc34f5 100755
--- a/scripts/leaking_addresses.pl
+++ b/scripts/leaking_addresses.pl
@@ -463,6 +463,16 @@ sub parse_file
 	close $fh;
 }
 
+# Checks if the actual path name is leaking a kernel address.
+sub check_path_for_leaks
+{
+	my ($path) = @_;
+
+	if (may_leak_address($path)) {
+		printf("Path name may contain address: $path\n");
+	}
+}
+
 # Recursively walk directory tree.
 sub walk
 {
@@ -484,6 +494,8 @@ sub walk
 
 			next if (skip($path));
 
+			check_path_for_leaks($path);
+
 			if (-d $path) {
 				push @dirs, $path;
 				next;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] leaking_addresses: check if file name contains address
  2018-03-01 22:03 ` [PATCH 2/2] leaking_addresses: check if file name contains address Tobin C. Harding
@ 2018-03-02  0:13   ` Tycho Andersen
  0 siblings, 0 replies; 4+ messages in thread
From: Tycho Andersen @ 2018-03-02  0:13 UTC (permalink / raw)
  To: Tobin C. Harding; +Cc: Kernel Hardening, LKML

On Fri, Mar 02, 2018 at 09:03:20AM +1100, Tobin C. Harding wrote:
> Sometimes files may be created by using output from printk.  As the scan
> traverses the directory tree we should parse each path name and check if
> it is leaking an address.
> 
> Add check for leaking address on each path name.
> 
> Suggested-by: Tycho Andersen <tycho@tycho.ws>

Acked-by: Tycho Andersen <tycho@tycho.ws>

> Signed-off-by: Tobin C. Harding <me@tobin.cc>
> ---
>  scripts/leaking_addresses.pl | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
> index 65a65aa64d26..a550c9bc34f5 100755
> --- a/scripts/leaking_addresses.pl
> +++ b/scripts/leaking_addresses.pl
> @@ -463,6 +463,16 @@ sub parse_file
>  	close $fh;
>  }
>  
> +# Checks if the actual path name is leaking a kernel address.
> +sub check_path_for_leaks
> +{
> +	my ($path) = @_;
> +
> +	if (may_leak_address($path)) {
> +		printf("Path name may contain address: $path\n");
> +	}
> +}
> +
>  # Recursively walk directory tree.
>  sub walk
>  {
> @@ -484,6 +494,8 @@ sub walk
>  
>  			next if (skip($path));
>  
> +			check_path_for_leaks($path);
> +
>  			if (-d $path) {
>  				push @dirs, $path;
>  				next;
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-02  0:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-01 22:03 [PATCH 0/2] leaking_addresses: check path name for leaks Tobin C. Harding
2018-03-01 22:03 ` [PATCH 1/2] leaking_addresses: explicitly name variable used in regex Tobin C. Harding
2018-03-01 22:03 ` [PATCH 2/2] leaking_addresses: check if file name contains address Tobin C. Harding
2018-03-02  0:13   ` Tycho Andersen

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®