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: <7a5d6dab-4d06-40b3-d9c7-09c991b856cd@intel.com>
Date:   Sun, 7 Nov 2021 11:51:37 -0800
From:   Dave Hansen <dave.hansen@...el.com>
To:     Jarkko Sakkinen <jarkko@...nel.org>
Cc:     Dave Hansen <dave.hansen@...ux.intel.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
        Jethro Beekman <jethro@...tanix.com>,
        Sean Christopherson <seanjc@...gle.com>,
        reinette.chatre@...el.com, tony.luck@...el.com,
        nathaniel@...fian.com, stable@...r.kernel.org,
        Borislav Petkov <bp@...e.de>, linux-sgx@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/sgx: Free backing memory after faulting the enclave
 page

On 11/7/21 11:42 AM, Jarkko Sakkinen wrote:
>>> It should be fairly effecient just to check the pages by using
>>> encl->page_tree.
>> That sounds more complicated and slower than what I suggested.  You
>> could even just check the refcount on the page.  I _think_ page cache
>> pages have a refcount of 2.  So, look for the refcount that means "no
>> more PCMD in this page", and just free it if so.
> Umh, so... there is total 32 PCMD's per one page.

When you place PCMD in a page, you do a get_page().  The refcount goes
up by one.  So, a PCMD page with one PCMD will (I think) have a refcount
of 3.  If you totally fill it up with 31 *more* PCMD entries, it will
have a refcount of 34.  You do *not* do a put_page() on the PCMD page at
the end of the allocation phase.

When the backing storage is freed, you drop the refcount.  So, going
from 32 PCMD entries to 31 entries in a page, you go from 34->33.

When that refcount drops to 2, you know there is no more data in the
page that's useful.  At that point you can truncate it out of the
backing storage.

There's no reason to scan the page, or a boatload of other metadata.
Just keep a refcount.  Just use the *existing* 'struct page' refcount.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ