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: <b1476c7d-c514-227f-2735-092b5afb7d3a@intel.com>
Date:   Mon, 18 Jul 2022 11:52:54 -0700
From:   Dave Hansen <dave.hansen@...el.com>
To:     Borislav Petkov <bp@...en8.de>,
        Kristen Carlson Accardi <kristen@...ux.intel.com>
Cc:     linux-tip-commits@...r.kernel.org,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Shakeel Butt <shakeelb@...gle.com>,
        Roman Gushchin <roman.gushchin@...ux.dev>, x86@...nel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [tip: x86/urgent] x86/sgx: Set active memcg prior to shmem
 allocation

On 7/18/22 02:50, Borislav Petkov wrote:
>> -int sgx_encl_get_backing(struct sgx_encl *encl, unsigned long page_index,
>> -			 struct sgx_backing *backing);
>> +int sgx_encl_lookup_backing(struct sgx_encl *encl, unsigned long page_index,
>> +			    struct sgx_backing *backing);
>> +int sgx_encl_alloc_backing(struct sgx_encl *encl, unsigned long page_index,
>> +			   struct sgx_backing *backing);
>>  void sgx_encl_put_backing(struct sgx_backing *backing);
> So this is making the sgx_encl_get_backing() thing static but its
> counterpart sgx_encl_put_backing() is not and is still called by other
> places.
> 
> Perhaps something wrong with the layering or is this on purpose?

All three of the:

	sgx_encl_get_backing()
	sgx_encl_lookup_backing()
	sgx_encl_alloc_backing()

functions take a reference on the backing storage that must be dropped
with sgx_encl_put_backing().  The "lookup" and "alloc" were added
because there really are two different users:

	1. I want to *create* backing storage space (alloc)
	2. I want to find *existing* backing storage (lookup)

and those two logical uses need different cgroup accounting semantics.

As a further cleanup, it would probably be nice to explicitly document
that "lookup" and "alloc" also require a subsequent "put".  It would
also be nice to change sgx_encl_get_backing() to
__sgx_encl_get_backing() to make it clear that it's an internal thing.

So, I think the _code_ is OK as-is, but it could use some more love.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ