Linux-Sgx Archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Borys <borysp@invisiblethingslab.com>
Cc: dave.hansen@linux.intel.com, linux-sgx@vger.kernel.org,
	mkow@invisiblethingslab.com
Subject: Re: sgx_validate_offset_length bug
Date: Wed, 5 Oct 2022 02:13:26 +0300	[thread overview]
Message-ID: <Yzy+Fv/v+Lqg0Ee/@kernel.org> (raw)
In-Reply-To: <65cc7f00-30e8-3cd4-7c1c-c50ca1e0bd42@invisiblethingslab.com>

On Wed, Oct 05, 2022 at 01:02:39AM +0200, Borys wrote:
> On 10/4/22 23:50, Jarkko Sakkinen wrote:
> > On Mon, Oct 03, 2022 at 07:19:21PM +0200, Borys wrote:
> >> Hi,
> >>
> >> 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.
> >>
> >> Best regards,
> >>
> >> Borys
> >>
> > 
> > I agree with the bug but not on security issue.
> > 
> > If you can call the ioctl API in the first place, you can already apply
> > the operations in arbitrary locations inside the enclave, i.e. it does
> > not introduce any new capability to the untrusted runtime.
> > 
> > BR, Jarkko
> 
> I meant it could possibly enable some local priv escalation, if other
> code has wrong assumptions. But again, this is purely theoretical,
> current usages fail on invalid values anyway.
> 
> Best regards,
> Borys

Yeah, in all cases it needs to be fixed. Thanks for pointing it out.

BR, Jarkko

      reply	other threads:[~2022-10-04 23:14 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
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 [this message]

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=Yzy+Fv/v+Lqg0Ee/@kernel.org \
    --to=jarkko@kernel.org \
    --cc=borysp@invisiblethingslab.com \
    --cc=dave.hansen@linux.intel.com \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).