From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <20171129101640.GC6217@eros> <20171129204812.GE6217@eros> <1512133747.17323.3.camel@gmail.com> <20171204001106.GB27780@eros> <1512362481.17323.9.camel@gmail.com> <20171204045522.GE27780@eros> <20171204082111.GB21565@eros> <1512382841.17323.11.camel@gmail.com> From: Kaiwan N Billimoria Date: Mon, 4 Dec 2017 18:58:49 +0530 Message-ID: Content-Type: multipart/alternative; boundary="001a113d0efa0f598e055f83b459" Subject: [kernel-hardening] Re: [PATCH] leaking_addresses: add support for 32-bit kernel addresses To: Alexander Kapshuk Cc: "Tobin C. Harding" , linux-kernel , kernel-hardening@lists.openwall.com List-ID: --001a113d0efa0f598e055f83b459 Content-Type: text/plain; charset="UTF-8" Sure, thanks Alexander.. Tobin, request you to pl make the change while merging, thanks.. Thanks & Regards, Kaiwan. On Mon, Dec 4, 2017 at 6:07 PM, Alexander Kapshuk < alexander.kapshuk@gmail.com> wrote: > On Mon, Dec 4, 2017 at 12:20 PM, wrote: > > On Mon, 2017-12-04 at 19:21 +1100, Tobin C. Harding wrote: > >> On Mon, Dec 04, 2017 at 10:51:53AM +0530, Kaiwan N Billimoria wrote: > >> > > --- > >> > diff --git a/scripts/leaking_addresses.pl b/scripts/ > leaking_addresses.pl > >> > index 9906dcf8b807..260b52e456f1 100755 > >> > --- a/scripts/leaking_addresses.pl > >> > +++ b/scripts/leaking_addresses.pl > >> > @@ -266,7 +266,7 @@ sub is_false_positive > >> > sub is_false_positive_ix86_32 > >> > { > >> > my ($match) = @_; > >> > - state $page_offset = eval get_page_offset(); # only gets > called once > >> > + state $page_offset = hex get_page_offset(); # only gets > called once > >> > >> I don't think this is valid ;) I meant use hex() to convert the string > >> to an int so it doesn't throw the warning (inside get_page_offset()). > > > > Yup, got it, thanks :-p > > Combined patch below: > > > > > > --- > > scripts/leaking_addresses.pl | 13 ++++++------- > > 1 file changed, 6 insertions(+), 7 deletions(-) > > > > diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl > > index 9906dcf8b807..a595a2c66b12 100755 > > --- a/scripts/leaking_addresses.pl > > +++ b/scripts/leaking_addresses.pl > > @@ -266,8 +266,7 @@ sub is_false_positive > > sub is_false_positive_ix86_32 > > { > > my ($match) = @_; > > - state $page_offset = eval get_page_offset(); # only gets called > once > > - > > + state $page_offset = get_page_offset(); # only gets called once > > if ($match =~ '\b(0x)?(f|F){8}\b') { > > return 1; > > } > > @@ -283,7 +282,7 @@ sub is_false_positive_ix86_32 > > sub get_page_offset > > { > > my $page_offset; > > - my $default_offset = "0xc0000000"; > > + my $default_offset = hex("0xc0000000"); > > my @config_files; > > > > # Allow --page-offset-32bit to override. > > @@ -306,23 +305,23 @@ sub get_page_offset > > } else { > > $page_offset = parse_kernel_config_file($tmp_ > file); > > if ($page_offset ne "") { > > - return $page_offset; > > + return hex($page_offset); > > } > > } > > system("rm -f $tmp_file"); > > } > > > > foreach my $config_file (@config_files) { > > - $config_file =~ s/\R*//g; > > + chomp $config_file; > > $page_offset = parse_kernel_config_file($config_file); > > if ($page_offset ne "") { > > - return $page_offset; > > + return hex($page_offset); > > } > > } > > > > printf STDERR "\nFailed to parse kernel config files\n"; > > printf STDERR "*** NOTE ***\n"; > > - printf STDERR "Falling back to PAGE_OFFSET = %s\n\n", > $default_offset; > > + printf STDERR "Falling back to PAGE_OFFSET = 0x%x\n\n", > $default_offset; > > Better use the '#' flag with the 'x' conversion specifier: > perl -e 'my $default_offset = hex("0xc0000000");printf "%#x\n", > $default_offset' > 0xc0000000 > > > > > return $default_offset; > > } > > -- > > 2.14.3 > > > > Thanks, > > Kaiwan. > > > >> thanks, > >> Tobin. > --001a113d0efa0f598e055f83b459 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Sure, thanks Alexander..
Tobin, request you to pl make the change while merging, thanks..<= /div>


Thanks & Regards,
Kaiwan.

On Mon, Dec 4, 2017 at 6:07 PM, Alexander Ka= pshuk <alexander.kapshuk@gmail.com> wrote:
On Mon, = Dec 4, 2017 at 12:20 PM,=C2=A0 <kaiwan.billimoria@gmail.com> wrote:
> On Mon, 2017-12-04 at 19:21 +1100, Tobin C. Harding wrote:
>> On Mon, Dec 04, 2017 at 10:51:53AM +0530, Kaiwan N Billimoria wrot= e:
>> > > ---
>> > diff --git a/scripts/leaking_addresses.pl b/scripts/l= eaking_addresses.pl
>> > index 9906dcf8b807..260b52e456f1 100755
>> > --- a/scripts/leaking_addresses.pl
>> > +++ b/scripts/leaking_addresses.pl
>> > @@ -266,7 +266,7 @@ sub is_false_positive
>> >=C2=A0 sub is_false_positive_ix86_32
>> >=C2=A0 {
>> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0my ($match) =3D @_;
>> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0state $page_offset =3D eval get_p= age_offset(); # only gets called once
>> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0state $page_offset =3D hex get_pa= ge_offset(); # only gets called once
>>
>> I don't think this is valid ;) I meant use hex() to convert th= e string
>> to an int so it doesn't throw the warning (inside get_page_off= set()).
>
> Yup, got it, thanks=C2=A0 =C2=A0:-p
> Combined patch below:
>
>
> ---
>=C2=A0 scripts/leaking_addresses.pl | 13 ++++++-------
>=C2=A0 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_ad= dresses.pl
> index 9906dcf8b807..a595a2c66b12 100755
> --- a/scripts/leaking_addresses.pl
> +++ b/scripts/leaking_addresses.pl
> @@ -266,8 +266,7 @@ sub is_false_positive
>=C2=A0 sub is_false_positive_ix86_32
>=C2=A0 {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0my ($match) =3D @_;
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0state $page_offset =3D eval get_page_offse= t(); # only gets called once
> -
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0state $page_offset =3D get_page_offset(); = # only gets called once
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if ($match =3D~ '\b(0x)?(f|F){8}\= b') {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return 1;=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> @@ -283,7 +282,7 @@ sub is_false_positive_ix86_32
>=C2=A0 sub get_page_offset
>=C2=A0 {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0my $page_offset;
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0my $default_offset =3D "0xc0000000&qu= ot;;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0my $default_offset =3D hex("0xc000000= 0");
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0my @config_files;
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Allow --page-offset-32bit to overri= de.
> @@ -306,23 +305,23 @@ sub get_page_offset
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} else {<= br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0$page_offset =3D parse_kernel_config_file($tmp_fil= e);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0if ($page_offset ne "") {
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return $page_offset;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return hex($page_offset);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0system(&q= uot;rm -f $tmp_file");
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0foreach my $config_file (@config_file= s) {
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$config_file = =3D~ s/\R*//g;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0chomp $config_= file;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$page_off= set =3D parse_kernel_config_file($config_file);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if ($page= _offset ne "") {
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0return $page_offset;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0return hex($page_offset);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0printf STDERR "\nFailed to parse= kernel config files\n";
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0printf STDERR "*** NOTE ***\n&qu= ot;;
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0printf STDERR "Falling back to PAGE_O= FFSET =3D %s\n\n", $default_offset;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0printf STDERR "Falling back to PAGE_O= FFSET =3D 0x%x\n\n", $default_offset;

Better use the '#' flag with the 'x' conversion= specifier:
perl -e 'my $default_offset =3D hex("0xc0000000");printf &quo= t;%#x\n", $default_offset'
0xc0000000

>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return $default_offset;
>=C2=A0 }
> --
> 2.14.3
>
> Thanks,
> Kaiwan.
>
>> thanks,
>> Tobin.

--001a113d0efa0f598e055f83b459--