kernel-hardening.lists.openwall.com archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Minor bug fixes to leaking_addresses.pl
@ 2019-02-07 22:50 Tobin C. Harding
  2019-02-07 22:50 ` [PATCH 1/3] leaking_addresses: Fix calls to dprint Tobin C. Harding
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Tobin C. Harding @ 2019-02-07 22:50 UTC (permalink / raw)
  To: kernel-hardening; +Cc: Tobin C. Harding, Tycho Andersen, linux-kernel

Hi,

Here are a few minor fixes/improvements to scripts/leaking_addresses.pl

Patch 1: Fixes places where I don't know how to Perl.

Patch 2: Removes `--version` command line option, completely this time.

Patch 3: Fix a bug in the command line options parsing.

thanks,
Tobin.


Tobin C. Harding (3):
  leaking_addresses: Fix calls to dprint
  leaking_addresses: Completely remove --version flag
  leaking_addresses: Expand tilde in output file name

 scripts/leaking_addresses.pl | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

-- 
2.20.1

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

* [PATCH 1/3] leaking_addresses: Fix calls to dprint
  2019-02-07 22:50 [PATCH 0/3] Minor bug fixes to leaking_addresses.pl Tobin C. Harding
@ 2019-02-07 22:50 ` Tobin C. Harding
  2019-02-07 22:50 ` [PATCH 2/3] leaking_addresses: Completely remove --version flag Tobin C. Harding
  2019-02-07 22:50 ` [PATCH 3/3] leaking_addresses: Expand tilde in output file name Tobin C. Harding
  2 siblings, 0 replies; 10+ messages in thread
From: Tobin C. Harding @ 2019-02-07 22:50 UTC (permalink / raw)
  To: kernel-hardening; +Cc: Tobin C. Harding, Tycho Andersen, linux-kernel

Currently calls to function dprint() are non uniform and at times
incorrect.

Use uniform _correct_ call to function dprint().

Signed-off-by: Tobin C. Harding <tobin@kernel.org>
---
 scripts/leaking_addresses.pl | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
index 6a897788f5a7..214c12be8c86 100755
--- a/scripts/leaking_addresses.pl
+++ b/scripts/leaking_addresses.pl
@@ -231,7 +231,7 @@ sub get_kernel_config_option
 		my $tmp_file = "/tmp/tmpkconf";
 
 		if (system("gunzip < /proc/config.gz > $tmp_file")) {
-			dprint "$0: system(gunzip < /proc/config.gz) failed\n";
+			dprint("system(gunzip < /proc/config.gz) failed\n");
 			return "";
 		} else {
 			@config_files = ($tmp_file);
@@ -243,7 +243,7 @@ sub get_kernel_config_option
 	}
 
 	foreach my $file (@config_files) {
-		dprint("parsing config file: %s\n", $file);
+		dprint("parsing config file: $file\n");
 		$value = option_from_file($option, $file);
 		if ($value ne "") {
 			last;
@@ -502,7 +502,7 @@ sub walk
 				next;
 			}
 
-			dprint "parsing: $path\n";
+			dprint("parsing: $path\n");
 			timed_parse_file($path);
 		}
 	}
-- 
2.20.1

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

* [PATCH 2/3] leaking_addresses: Completely remove --version flag
  2019-02-07 22:50 [PATCH 0/3] Minor bug fixes to leaking_addresses.pl Tobin C. Harding
  2019-02-07 22:50 ` [PATCH 1/3] leaking_addresses: Fix calls to dprint Tobin C. Harding
@ 2019-02-07 22:50 ` Tobin C. Harding
  2019-02-07 22:50 ` [PATCH 3/3] leaking_addresses: Expand tilde in output file name Tobin C. Harding
  2 siblings, 0 replies; 10+ messages in thread
From: Tobin C. Harding @ 2019-02-07 22:50 UTC (permalink / raw)
  To: kernel-hardening; +Cc: Tobin C. Harding, Tycho Andersen, linux-kernel

Recently attempt to remove the '--version' flag was made, badly.  I
failed to remove mention of it from the help output.  And also I failed
to actually remove the flag from the options list.

_Completely_ remove --version flag.

Signed-off-by: Tobin C. Harding <tobin@kernel.org>
---
 scripts/leaking_addresses.pl | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
index 214c12be8c86..ef9e5b2a1614 100755
--- a/scripts/leaking_addresses.pl
+++ b/scripts/leaking_addresses.pl
@@ -97,7 +97,7 @@ Options:
 	--32-bit			Scan 32-bit kernel.
 	--page-offset-32-bit=o		Page offset (for 32-bit kernel 0xABCD1234).
 	-d, --debug			Display debugging output.
-	-h, --help, --version		Display this help and exit.
+	-h, --help			Display this help and exit.
 
 Scans the running kernel for potential leaking addresses.
 
@@ -108,7 +108,6 @@ EOM
 GetOptions(
 	'd|debug'		=> \$debug,
 	'h|help'		=> \$help,
-	'version'		=> \$help,
 	'o|output-raw=s'        => \$output_raw,
 	'i|input-raw=s'         => \$input_raw,
 	'suppress-dmesg'        => \$suppress_dmesg,
-- 
2.20.1

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

* [PATCH 3/3] leaking_addresses: Expand tilde in output file name
  2019-02-07 22:50 [PATCH 0/3] Minor bug fixes to leaking_addresses.pl Tobin C. Harding
  2019-02-07 22:50 ` [PATCH 1/3] leaking_addresses: Fix calls to dprint Tobin C. Harding
  2019-02-07 22:50 ` [PATCH 2/3] leaking_addresses: Completely remove --version flag Tobin C. Harding
@ 2019-02-07 22:50 ` Tobin C. Harding
  2019-02-07 23:35   ` Tycho Andersen
  2019-02-13 15:56   ` David Laight
  2 siblings, 2 replies; 10+ messages in thread
From: Tobin C. Harding @ 2019-02-07 22:50 UTC (permalink / raw)
  To: kernel-hardening; +Cc: Tobin C. Harding, Tycho Andersen, linux-kernel

Currently if user passes an output file to the script via
--output-raw we do not handle expansion of tilde.

Use perl function glob() to expand tilde in output file name.

Signed-off-by: Tobin C. Harding <tobin@kernel.org>
---
 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 ef9e5b2a1614..ce545ca3fb70 100755
--- a/scripts/leaking_addresses.pl
+++ b/scripts/leaking_addresses.pl
@@ -150,7 +150,7 @@ if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) {
 }
 
 if ($output_raw) {
-	open my $fh, '>', $output_raw or die "$0: $output_raw: $!\n";
+	open my $fh, '>', glob($output_raw) or die "$0: $output_raw: $!\n";
 	select $fh;
 }
 
-- 
2.20.1

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

* Re: [PATCH 3/3] leaking_addresses: Expand tilde in output file name
  2019-02-07 22:50 ` [PATCH 3/3] leaking_addresses: Expand tilde in output file name Tobin C. Harding
@ 2019-02-07 23:35   ` Tycho Andersen
  2019-02-09  6:01     ` Tobin C. Harding
  2019-02-14  4:13     ` Tobin C. Harding
  2019-02-13 15:56   ` David Laight
  1 sibling, 2 replies; 10+ messages in thread
From: Tycho Andersen @ 2019-02-07 23:35 UTC (permalink / raw)
  To: Tobin C. Harding; +Cc: kernel-hardening, linux-kernel

On Fri, Feb 08, 2019 at 09:50:26AM +1100, Tobin C. Harding wrote:
> Currently if user passes an output file to the script via
> --output-raw we do not handle expansion of tilde.
> 
> Use perl function glob() to expand tilde in output file name.
> 
> Signed-off-by: Tobin C. Harding <tobin@kernel.org>
> ---
>  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 ef9e5b2a1614..ce545ca3fb70 100755
> --- a/scripts/leaking_addresses.pl
> +++ b/scripts/leaking_addresses.pl
> @@ -150,7 +150,7 @@ if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) {
>  }
>  
>  if ($output_raw) {
> -	open my $fh, '>', $output_raw or die "$0: $output_raw: $!\n";
> +	open my $fh, '>', glob($output_raw) or die "$0: $output_raw: $!\n";

Seems like you might also have the same problem with $input_raw? I
wonder if you can just do this in GetOptions somehow, so that all
users of these further down in the script don't have to remember to do
this.

Cheers,

Tycho

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

* Re: [PATCH 3/3] leaking_addresses: Expand tilde in output file name
  2019-02-07 23:35   ` Tycho Andersen
@ 2019-02-09  6:01     ` Tobin C. Harding
  2019-02-14  4:13     ` Tobin C. Harding
  1 sibling, 0 replies; 10+ messages in thread
From: Tobin C. Harding @ 2019-02-09  6:01 UTC (permalink / raw)
  To: Tycho Andersen; +Cc: Tobin C. Harding, kernel-hardening, linux-kernel

On Thu, Feb 07, 2019 at 04:35:55PM -0700, Tycho Andersen wrote:
> On Fri, Feb 08, 2019 at 09:50:26AM +1100, Tobin C. Harding wrote:
> > Currently if user passes an output file to the script via
> > --output-raw we do not handle expansion of tilde.
> > 
> > Use perl function glob() to expand tilde in output file name.
> > 
> > Signed-off-by: Tobin C. Harding <tobin@kernel.org>
> > ---
> >  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 ef9e5b2a1614..ce545ca3fb70 100755
> > --- a/scripts/leaking_addresses.pl
> > +++ b/scripts/leaking_addresses.pl
> > @@ -150,7 +150,7 @@ if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) {
> >  }
> >  
> >  if ($output_raw) {
> > -	open my $fh, '>', $output_raw or die "$0: $output_raw: $!\n";
> > +	open my $fh, '>', glob($output_raw) or die "$0: $output_raw: $!\n";
> 
> Seems like you might also have the same problem with $input_raw? I
> wonder if you can just do this in GetOptions somehow, so that all
> users of these further down in the script don't have to remember to do
> this.

Thanks for the review, good idea - I'll look into it.

       Tobin

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

* RE: [PATCH 3/3] leaking_addresses: Expand tilde in output file name
  2019-02-07 22:50 ` [PATCH 3/3] leaking_addresses: Expand tilde in output file name Tobin C. Harding
  2019-02-07 23:35   ` Tycho Andersen
@ 2019-02-13 15:56   ` David Laight
  2019-02-13 20:30     ` Tobin C. Harding
  1 sibling, 1 reply; 10+ messages in thread
From: David Laight @ 2019-02-13 15:56 UTC (permalink / raw)
  To: 'Tobin C. Harding', kernel-hardening; +Cc: Tycho Andersen, linux-kernel

From: Tobin C. Harding
> Sent: 07 February 2019 22:50
> 
> Currently if user passes an output file to the script via
> --output-raw we do not handle expansion of tilde.
> 
> Use perl function glob() to expand tilde in output file name.

What happens if glob() returns multiple files?
I'm guessing that it can...

	David

> Signed-off-by: Tobin C. Harding <tobin@kernel.org>
> ---
>  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 ef9e5b2a1614..ce545ca3fb70 100755
> --- a/scripts/leaking_addresses.pl
> +++ b/scripts/leaking_addresses.pl
> @@ -150,7 +150,7 @@ if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) {
>  }
> 
>  if ($output_raw) {
> -	open my $fh, '>', $output_raw or die "$0: $output_raw: $!\n";
> +	open my $fh, '>', glob($output_raw) or die "$0: $output_raw: $!\n";
>  	select $fh;
>  }
> 
> --
> 2.20.1

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

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

* Re: [PATCH 3/3] leaking_addresses: Expand tilde in output file name
  2019-02-13 15:56   ` David Laight
@ 2019-02-13 20:30     ` Tobin C. Harding
  2019-02-14  9:50       ` David Laight
  0 siblings, 1 reply; 10+ messages in thread
From: Tobin C. Harding @ 2019-02-13 20:30 UTC (permalink / raw)
  To: David Laight
  Cc: 'Tobin C. Harding',
	kernel-hardening, Tycho Andersen, linux-kernel

On Wed, Feb 13, 2019 at 03:56:47PM +0000, David Laight wrote:
> From: Tobin C. Harding
> > Sent: 07 February 2019 22:50
> > 
> > Currently if user passes an output file to the script via
> > --output-raw we do not handle expansion of tilde.
> > 
> > Use perl function glob() to expand tilde in output file name.
> 
> What happens if glob() returns multiple files?
> I'm guessing that it can...

Thanks for taking a look at this David.  Surely glob() cannot return
multiple values when expanding tilde?  If someone passes a '*' into the
command as an input/output file then they are clearly mad :)


thanks,
Tobin.

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

* Re: [PATCH 3/3] leaking_addresses: Expand tilde in output file name
  2019-02-07 23:35   ` Tycho Andersen
  2019-02-09  6:01     ` Tobin C. Harding
@ 2019-02-14  4:13     ` Tobin C. Harding
  1 sibling, 0 replies; 10+ messages in thread
From: Tobin C. Harding @ 2019-02-14  4:13 UTC (permalink / raw)
  To: Tycho Andersen; +Cc: Tobin C. Harding, kernel-hardening, linux-kernel

On Thu, Feb 07, 2019 at 04:35:55PM -0700, Tycho Andersen wrote:
> On Fri, Feb 08, 2019 at 09:50:26AM +1100, Tobin C. Harding wrote:
> > Currently if user passes an output file to the script via
> > --output-raw we do not handle expansion of tilde.
> > 
> > Use perl function glob() to expand tilde in output file name.
> > 
> > Signed-off-by: Tobin C. Harding <tobin@kernel.org>
> > ---
> >  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 ef9e5b2a1614..ce545ca3fb70 100755
> > --- a/scripts/leaking_addresses.pl
> > +++ b/scripts/leaking_addresses.pl
> > @@ -150,7 +150,7 @@ if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) {
> >  }
> >  
> >  if ($output_raw) {
> > -	open my $fh, '>', $output_raw or die "$0: $output_raw: $!\n";
> > +	open my $fh, '>', glob($output_raw) or die "$0: $output_raw: $!\n";
> 
> Seems like you might also have the same problem with $input_raw? I
> wonder if you can just do this in GetOptions somehow, so that all
> users of these further down in the script don't have to remember to do
> this.

I don't know what changed between now and when I first wrote this patch
(a fair while ago) but I just tested with bash and zsh _without_ this
patch and tilde was handled fine.

Dropping this patch, moving the other two onto leaks-next.

thanks,
Tobin.

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

* RE: [PATCH 3/3] leaking_addresses: Expand tilde in output file name
  2019-02-13 20:30     ` Tobin C. Harding
@ 2019-02-14  9:50       ` David Laight
  0 siblings, 0 replies; 10+ messages in thread
From: David Laight @ 2019-02-14  9:50 UTC (permalink / raw)
  To: 'Tobin C. Harding'
  Cc: 'Tobin C. Harding',
	kernel-hardening, Tycho Andersen, linux-kernel

From: Tobin C. Harding
> Sent: 13 February 2019 20:31
> 
> On Wed, Feb 13, 2019 at 03:56:47PM +0000, David Laight wrote:
> > From: Tobin C. Harding
> > > Sent: 07 February 2019 22:50
> > >
> > > Currently if user passes an output file to the script via
> > > --output-raw we do not handle expansion of tilde.
> > >
> > > Use perl function glob() to expand tilde in output file name.
> >
> > What happens if glob() returns multiple files?
> > I'm guessing that it can...
> 
> Thanks for taking a look at this David.  Surely glob() cannot return
> multiple values when expanding tilde?  If someone passes a '*' into the
> command as an input/output file then they are clearly mad :)

Yes, but the perl script will go horribly wrong.

Actually, how do they get a ~ in there?
Whatever shell generated perl's argv[] would be expected to handle it.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

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

end of thread, other threads:[~2019-02-14  9:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-07 22:50 [PATCH 0/3] Minor bug fixes to leaking_addresses.pl Tobin C. Harding
2019-02-07 22:50 ` [PATCH 1/3] leaking_addresses: Fix calls to dprint Tobin C. Harding
2019-02-07 22:50 ` [PATCH 2/3] leaking_addresses: Completely remove --version flag Tobin C. Harding
2019-02-07 22:50 ` [PATCH 3/3] leaking_addresses: Expand tilde in output file name Tobin C. Harding
2019-02-07 23:35   ` Tycho Andersen
2019-02-09  6:01     ` Tobin C. Harding
2019-02-14  4:13     ` Tobin C. Harding
2019-02-13 15:56   ` David Laight
2019-02-13 20:30     ` Tobin C. Harding
2019-02-14  9:50       ` David Laight

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).