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]
Date:   Tue, 22 Aug 2023 13:10:57 +0300
From:   "Jarkko Sakkinen" <jarkko@...nel.org>
To:     "Jo Van Bulck" <jo.vanbulck@...kuleuven.be>, <kai.huang@...el.com>,
        <linux-sgx@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Cc:     <dave.hansen@...ux.intel.com>
Subject: Re: [PATCH v3 6/9] selftests/sgx: Ensure test enclave buffer is
 entirely preserved

On Sat Aug 19, 2023 at 12:43 PM EEST, Jo Van Bulck wrote:
> Attach the "used" attribute to instruct the compiler to preserve the static
> encl_buffer, even if it appears it is not entirely referenced in the enclave
> code, as expected by the external tests manipulating page permissions.
>
> Link: https://lore.kernel.org/all/a2732938-f3db-a0af-3d68-a18060f66e79@cs.kuleuven.be/
> Signed-off-by: Jo Van Bulck <jo.vanbulck@...kuleuven.be>
> ---
>  tools/testing/selftests/sgx/defines.h   | 1 +
>  tools/testing/selftests/sgx/test_encl.c | 9 +++++----
>  2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/sgx/defines.h b/tools/testing/selftests/sgx/defines.h
> index d8587c971..b8f482667 100644
> --- a/tools/testing/selftests/sgx/defines.h
> +++ b/tools/testing/selftests/sgx/defines.h
> @@ -13,6 +13,7 @@
>  
>  #define __aligned(x) __attribute__((__aligned__(x)))
>  #define __packed __attribute__((packed))
> +#define __used __attribute__((used))
>  
>  #include "../../../../arch/x86/include/asm/sgx.h"
>  #include "../../../../arch/x86/include/asm/enclu.h"
> diff --git a/tools/testing/selftests/sgx/test_encl.c b/tools/testing/selftests/sgx/test_encl.c
> index b09550cb3..c7bcbc85b 100644
> --- a/tools/testing/selftests/sgx/test_encl.c
> +++ b/tools/testing/selftests/sgx/test_encl.c
> @@ -5,11 +5,12 @@
>  #include "defines.h"
>  
>  /*
> - * Data buffer spanning two pages that will be placed first in .data
> - * segment. Even if not used internally the second page is needed by
> - * external test manipulating page permissions.
> + * Data buffer spanning two pages that will be placed first in the .data
> + * segment. Even if not used internally the second page is needed by external
> + * test manipulating page permissions, so mark encl_buffer as "used" to make
> + * sure it is entirely preserved by the compiler.
>   */
> -static uint8_t encl_buffer[8192] = { 1 };
> +static uint8_t __used encl_buffer[8192] = { 1 };
>  
>  enum sgx_enclu_function {
>  	EACCEPT = 0x5,
> -- 
> 2.25.1

Reviewed-by: Jarkko Sakkinen <jarkko@...nel.org>

BR, Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ