linux-sgx.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: linux-sgx@vger.kernel.org
Cc: sean.j.christopherson@intel.com, serge.ayoun@intel.com,
	shay.katz-zamir@intel.com,
	Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Subject: [PATCH 2/4] x86/sgx: Validate TCS permssions in sgx_validate_secinfo()
Date: Fri, 23 Aug 2019 19:16:14 +0300	[thread overview]
Message-ID: <20190823161616.27644-3-jarkko.sakkinen@linux.intel.com> (raw)
In-Reply-To: <20190823161616.27644-1-jarkko.sakkinen@linux.intel.com>

The validation of TCS permissions was missing from
sgx_validate_secinfo(). This patch adds the validation.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 arch/x86/kernel/cpu/sgx/ioctl.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c
index f9eef0f2125f..5423d7c45d5e 100644
--- a/arch/x86/kernel/cpu/sgx/ioctl.c
+++ b/arch/x86/kernel/cpu/sgx/ioctl.c
@@ -298,6 +298,13 @@ static int sgx_validate_secinfo(struct sgx_secinfo *secinfo)
 	if ((perm & SGX_SECINFO_W) && !(perm & SGX_SECINFO_R))
 		return -EINVAL;
 
+	/*
+	 * CPU will silently overwrite the permissions as zero, which means
+	 * that we need to validate it ourselves.
+	 */
+	if (pt == SGX_SECINFO_TCS && perm)
+		return -EINVAL;
+
 	if (secinfo->flags & SGX_SECINFO_RESERVED_MASK)
 		return -EINVAL;
 
-- 
2.20.1


  parent reply	other threads:[~2019-08-23 16:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23 16:16 [PATCH 0/4] Remaining updates for v22 Jarkko Sakkinen
2019-08-23 16:16 ` [PATCH 1/4] x86/sgx: Replace @is_secs_child with @pt in sgx_encl_ewb() Jarkko Sakkinen
2019-08-26 14:31   ` Ayoun, Serge
2019-08-26 16:25     ` Jarkko Sakkinen
2019-08-23 16:16 ` Jarkko Sakkinen [this message]
2019-08-23 16:16 ` [PATCH 3/4] x86/sgx: Remove a deperecated enum Jarkko Sakkinen
2019-08-23 16:16 ` [PATCH 4/4] x86/sgx: Move VM prot bits calculation to sgx_encl_page_alloc() Jarkko Sakkinen
2019-08-23 21:53 ` [PATCH 0/4] Remaining updates for v22 Sean Christopherson
2019-08-26  5:39   ` Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190823161616.27644-3-jarkko.sakkinen@linux.intel.com \
    --to=jarkko.sakkinen@linux.intel.com \
    --cc=linux-sgx@vger.kernel.org \
    --cc=sean.j.christopherson@intel.com \
    --cc=serge.ayoun@intel.com \
    --cc=shay.katz-zamir@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).