All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: "Daniel P. Smith" <dpsmith@apertussolutions.com>
Cc: <xen-devel@lists.xenproject.org>, <scott.davis@starlab.io>,
	<jandryuk@gmail.com>, Daniel De Graaf <dgdegra@tycho.nsa.gov>,
	Andrew Cooper <Andrew.Cooper3@citrix.com>
Subject: Re: [PATCH 1/2] xsm: add ability to elevate a domain to privileged
Date: Tue, 5 Apr 2022 17:01:53 +0200	[thread overview]
Message-ID: <YkxZ4RWAEKRSdUWL@Air-de-Roger> (raw)
In-Reply-To: <959fce1f-31c4-3de8-c3f2-45c307502473@apertussolutions.com>

On Tue, Apr 05, 2022 at 08:06:31AM -0400, Daniel P. Smith wrote:
> On 4/5/22 03:42, Roger Pau Monné wrote:
> > On Mon, Apr 04, 2022 at 12:08:25PM -0400, Daniel P. Smith wrote:
> >> On 4/4/22 11:12, Roger Pau Monné wrote:
> >>> On Mon, Apr 04, 2022 at 10:21:18AM -0400, Daniel P. Smith wrote:
> >>>> On 3/31/22 08:36, Roger Pau Monné wrote:
> >>>>> On Wed, Mar 30, 2022 at 07:05:48PM -0400, Daniel P. Smith wrote:
> >>>>>> diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
> >>>>>> index e22d6160b5..157e57151e 100644
> >>>>>> --- a/xen/include/xsm/xsm.h
> >>>>>> +++ b/xen/include/xsm/xsm.h
> >>>>>> @@ -189,6 +189,28 @@ struct xsm_operations {
> >>>>>>  #endif
> >>>>>>  };
> >>>>>>  
> >>>>>> +static always_inline int xsm_elevate_priv(struct domain *d)
> >>>>>
> >>>>> I don't think it needs to be always_inline, using just inline would be
> >>>>> fine IMO.
> >>>>>
> >>>>> Also this needs to be __init.
> >>>>
> >>>> AIUI always_inline is likely the best way to preserve the speculation
> >>>> safety brought in by the call to is_system_domain().
> >>>
> >>> There's nothing related to speculation safety in is_system_domain()
> >>> AFAICT. It's just a plain check against d->domain_id. It's my
> >>> understanding there's no need for any speculation barrier there
> >>> because d->domain_id is not an external input.
> >>
> >> Hmmm, this actually raises a good question. Why is is_control_domain(),
> >> is_hardware_domain, and others all have evaluate_nospec() wrapping the
> >> check of a struct domain element while is_system_domain() does not?
> > 
> > Jan replied to this regard, see:
> > 
> > https://lore.kernel.org/xen-devel/54272d08-7ce1-b162-c8e9-1955b780ca11@suse.com/
> 
> Jan can correct me if I misunderstood, but his point is with respect to
> where the inline function will be expanded into and I would think you
> would want to ensure that if anyone were to use is_system_domain(), then
> the inline expansion of this new location could create a potential
> speculation-able branch. Basically my concern is not putting the guards
> in place today just because there is not currently any location where
> is_system_domain() is expanded to create a speculation opportunity does
> not mean there is not an opening for the opportunity down the road for a
> future unprotected use.
> 
> >>> In any case this function should be __init only, at which point there
> >>> are no untrusted inputs to Xen.
> >>
> >> I thought it was agreed that __init on inline functions in headers had
> >> no meaning?
> > 
> > In a different reply I already noted my preference would be for the
> > function to not reside in a header and not be inline, simply because
> > it would be gone after initialization and we won't have to worry about
> > any stray calls when the system is active.
> 
> If an inline function is only used by __init code, how would be
> available for stray calls when the system is active? I would concede
> that it is possible for someone to explicitly use in not __init code but
> I would like to believe any usage in a submitted code change would be
> questioned by the reviewers.

Right, it's IMO easier when things just explode when not used
correctly, hence my suggestion to make it __init.

> With that said, if we consider Jason's suggestion would this remove your
> concern since that would only introduce a de-privilege function and
> there would be no piv escalation that could be erroneously called at
> anytime?

Indeed.  IMO everything that happens before the system switches to the
active state should be considered to be running in a privileged
context anyway.  Maybe others have different opinions.  Or maybe there
are use-cases I'm not aware of where this is not true.

Thanks, Roger.


  reply	other threads:[~2022-04-05 15:02 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-30 23:05 [PATCH 0/2] Introduce XSM ability for domain privilege escalation Daniel P. Smith
2022-03-30 23:05 ` [PATCH 1/2] xsm: add ability to elevate a domain to privileged Daniel P. Smith
2022-03-31 12:36   ` Roger Pau Monné
2022-04-01 17:52     ` Julien Grall
2022-04-04  8:08       ` Roger Pau Monné
2022-04-04 12:24         ` Jan Beulich
2022-04-04 14:21     ` Daniel P. Smith
2022-04-04 15:12       ` Roger Pau Monné
2022-04-04 15:17         ` Jan Beulich
2022-04-04 16:08         ` Daniel P. Smith
2022-04-05  7:42           ` Roger Pau Monné
2022-04-05 12:06             ` Daniel P. Smith
2022-04-05 15:01               ` Roger Pau Monné [this message]
2022-03-31 13:16   ` Jason Andryuk
2022-04-04 15:33     ` Daniel P. Smith
2022-04-05 17:17       ` Jason Andryuk
2022-04-05 19:05         ` Daniel P. Smith
2022-04-06  7:06         ` Jan Beulich
2022-04-06  8:46           ` Roger Pau Monné
2022-04-06  8:48             ` Jan Beulich
2022-04-06  9:09               ` Roger Pau Monné
2022-04-06  9:16                 ` Jan Beulich
2022-04-06  9:40                   ` Roger Pau Monné
2022-04-06 12:31           ` Jason Andryuk
2022-04-01 17:53   ` Julien Grall
2022-03-30 23:05 ` [PATCH 2/2] arch: ensure idle domain is not left privileged Daniel P. Smith
2022-03-31 12:46   ` Roger Pau Monné
2022-03-31 12:54     ` Julien Grall
2022-03-31 20:30       ` Stefano Stabellini
2022-04-04 14:56     ` Daniel P. Smith
2022-04-05  8:26   ` Jan Beulich
2022-04-05 12:24     ` Daniel P. Smith

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=YkxZ4RWAEKRSdUWL@Air-de-Roger \
    --to=roger.pau@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=dpsmith@apertussolutions.com \
    --cc=jandryuk@gmail.com \
    --cc=scott.davis@starlab.io \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.