From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA862C43461 for ; Mon, 3 May 2021 15:41:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0B3B61159 for ; Mon, 3 May 2021 15:41:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230424AbhECPl5 (ORCPT ); Mon, 3 May 2021 11:41:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:46854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbhECPl4 (ORCPT ); Mon, 3 May 2021 11:41:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C23B961159; Mon, 3 May 2021 15:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620056463; bh=h5qmhx+5ZVl78XWAQLNoSqoyVBg9I1Ilhgksiu+zPpQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gaTbWj4SLwG75jsCexmUqAGQ2vuj9dYXLYj0IwM4kCP28a0K9r0fGEBdTr8O0vplg lHjfSUBEUtvwfDW9vmZzR8Lmms1iRkS7izV/FJrthzXFwSmiVAtQPnJABjMLlx4I+L qfeJl/d6E+LZ8YuFKQosOwpCy1y/sT5IjWueBYPZzaVnAlZnkvoSnT/z5p+/uqQAvr Xgt3VFZTm7KeKfBwpwTpbmb0Nwa6cKSSPlq1EwOqDG/UlJfJPPNnaCF6AFM5OiSgCu jZuhYr3eHKzkoV/23MfhsEm8xDSqwU0WMtt9kfN/0rImIDrWrqTBZUmgRsmNRj40K3 A3Tujwm16NCUQ== Date: Mon, 3 May 2021 18:41:00 +0300 From: Jarkko Sakkinen To: Dave Hansen Cc: Tim Gardner , dave.hansen@linux.intel.com, shuah@kernel.org, linux-sgx@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Subject: [PATCH 0/1] SGX self test fails Message-ID: References: <20210429183952.22797-1-tim.gardner@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 29, 2021 at 11:55:23AM -0700, Dave Hansen wrote: > On 4/29/21 11:39 AM, Tim Gardner wrote: > > I'm just starting my learning curve on SGX, so I don't know if I've missed > > some setup for the SGX device entries. After looking at arch/x86/kernel/cpu/sgx/driver.c > > I see that there is no mode value for either sgx_dev_enclave or sgx_dev_provision. > > > > With this patch I can get the SGX self test to complete: > > > > sudo ./test_sgx > > Warning: no execute permissions on device file /dev/sgx_enclave > > 0x0000000000000000 0x0000000000002000 0x03 > > 0x0000000000002000 0x0000000000001000 0x05 > > 0x0000000000003000 0x0000000000003000 0x03 > > SUCCESS > > > > Is the warning even necessary ? > > Dang, I just added that warning. I thought it was necessary, but I > guess not: > > $ ls -l /dev/sgx_enclave > crw------- 1 dave dave 10, 125 Apr 28 11:32 /dev/sgx_enclave > $ ./test_sgx > 0x0000000000000000 0x0000000000002000 0x03 > 0x0000000000002000 0x0000000000001000 0x05 > 0x0000000000003000 0x0000000000003000 0x03 > SUCCESS > > *But*, is that OK? Should we be happily creating a PROT_EXEC mapping on > a ugo-x file? Why were we respecting noexec on the filesystem but not > ugo-x on the file? Yeah, this supports my earlier response: "EPERM The prot argument asks for PROT_EXEC but the mapped area belongs to a file on a filesystem that was mounted no-exec." https://man7.org/linux/man-pages/man2/mmap.2.html I guess the right model is to think just as "anonymous memory" with equivalent access control semantics after succesfully opened for read and write. BTW, this is good material for the man page :-) /Jarkko