public inbox for linux-sgx@vger.kernel.org
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: Borys <borysp@invisiblethingslab.com>, <jarkko@kernel.org>,
	<dave.hansen@linux.intel.com>, <linux-sgx@vger.kernel.org>
Cc: <mkow@invisiblethingslab.com>
Subject: Re: sgx_validate_offset_length bug
Date: Mon, 3 Oct 2022 10:33:35 -0700	[thread overview]
Message-ID: <956f6af2-e0cb-72c0-abf8-e2e00067851c@intel.com> (raw)
In-Reply-To: <9e1e61cf-39d9-8039-b2e4-f0a3804fe493@invisiblethingslab.com>

Hi Borys,

On 10/3/2022 10:19 AM, Borys wrote:
> I've stumbled upon "sgx_validate_offset_length" function in
> "arch/x86/kernel/cpu/sgx/ioctl.c" (all of this is based on 6.0-rc7
> version), which does not entirely do what it claims. "offset" and
> "length" parameters are provided by userspace and as such their
> addition can overflow, which may result in this function approving
> malicious values. Fortunately this does not result in any exploitable
> bugs at the moment (or at least I couldn't find any), but this might
> change if "sgx_validate_offset_length" is used in a new context or
> current usages are changed, so it might be worth fixing anyway.
> Simple overflow check `offset + length < offset` should be enough.> 

Could you please elaborate where you see a possibility for overflow?

Together the provided values, offset and length, are already ensured to
not exceed the total size of the enclave in the following check:

sgx_validate_offset_length() {
	...
	if (offset + length - PAGE_SIZE >= encl->size)
		return -EINVAL;
	...
}

Reinette

  reply	other threads:[~2022-10-03 17:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-03 17:19 sgx_validate_offset_length bug Borys
2022-10-03 17:33 ` Reinette Chatre [this message]
2022-10-03 17:58   ` Reinette Chatre
2022-10-04 13:22     ` Borys
2022-10-04 15:21       ` Reinette Chatre
2022-10-04 21:50 ` Jarkko Sakkinen
2022-10-04 23:02   ` Borys
2022-10-04 23:13     ` 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=956f6af2-e0cb-72c0-abf8-e2e00067851c@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=borysp@invisiblethingslab.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=jarkko@kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=mkow@invisiblethingslab.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