lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0cd3899b-cf3b-61c1-14ae-60b6b49d14ab@suse.com>
Date:   Mon, 22 May 2023 16:17:50 +0200
From:   Juergen Gross <jgross@...e.com>
To:     Borislav Petkov <bp@...en8.de>
Cc:     linux-kernel@...r.kernel.org, x86@...nel.org,
        linux-hyperv@...r.kernel.org, linux-doc@...r.kernel.org,
        mikelley@...rosoft.com, Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        "K. Y. Srinivasan" <kys@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        Wei Liu <wei.liu@...nel.org>, Dexuan Cui <decui@...rosoft.com>,
        Boris Ostrovsky <boris.ostrovsky@...cle.com>,
        xen-devel@...ts.xenproject.org, Jonathan Corbet <corbet@....net>,
        Andy Lutomirski <luto@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH v6 00/16] x86/mtrr: fix handling with PAT but without MTRR

On 11.05.23 18:32, Borislav Petkov wrote:
> On Wed, May 10, 2023 at 05:53:15PM +0200, Juergen Gross wrote:
>> Urgh, yes, there is something missing:
>>
>> diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c
>> index 031f7ea8e72b..9544e7d13bb3 100644
>> --- a/arch/x86/kernel/cpu/mtrr/generic.c
>> +++ b/arch/x86/kernel/cpu/mtrr/generic.c
>> @@ -521,8 +521,12 @@ u8 mtrr_type_lookup(u64 start, u64 end, u8 *uniform)
>>          for (i = 0; i < cache_map_n && start < end; i++) {
>>                  if (start >= cache_map[i].end)
>>                          continue;
> 
> So the loop will go through the map until...
> 
>> -               if (start < cache_map[i].start)
>> +               if (start < cache_map[i].start) {
> 
> ... it reaches the first entry where that is true.
> 
>>                          type = type_merge(type, mtrr_state.def_type, uniform);
> 
> the @type argument is MTRR_TYPE_INVALID, def_type is WRBACK so what
> this'll do is simply get you the default WRBACK type:
> 
> type_merge:
>          if (type == MTRR_TYPE_INVALID)
>                  return new_type;
> 
>> +                       start = cache_map[i].start;
>> +                       if (end <= start)
>> +                               break;
> 
> Now you break here because end <= start. Why?
> 
> You can just as well do:
> 
> 	if (start < cache_map[i].start) {
> 		/* region non-overlapping with the region in the map */
> 		if (end <= cache_map[i].start)
> 			return type_merge(type, mtrr_state.def_type, uniform);
> 
> 		... rest of the processing ...
> 
> In general, I get it that your code is slick but I want it to be
> maintainable - not slick. I'd like for when people look at this, not
> have to  add a bunch of debugging output in order to swap the whole
> thing back into their brains.
> 
> So mtrr_type_lookup() definitely needs comments explaining what goes
> where.
> 
> You can send it as a diff ontop - I'll merge it.

The attached diff is for patch 13.


Juergen


View attachment "diff.patch" of type "text/x-patch" (1143 bytes)

Download attachment "OpenPGP_0xB0DE9DD628BF132F.asc" of type "application/pgp-keys" (3099 bytes)

Download attachment "OpenPGP_signature" of type "application/pgp-signature" (496 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ