xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Zhongze Liu <blackskygg@gmail.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	George Dunlap <george.dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	xen-devel@lists.xen.org, Julien Grall <julien.grall@arm.com>,
	Daniel De Graaf <dgdegra@tycho.nsa.gov>
Subject: Re: [PATCH 4/6] xsm: flask: change the interface and default policy for xsm_map_gmfn_foregin
Date: Thu, 24 Aug 2017 08:51:39 +0800	[thread overview]
Message-ID: <CAHrd_jpUPfeks4j7+UE0NkZbzHtUWhcQmV4W_z-t+JB41FJQmA@mail.gmail.com> (raw)
In-Reply-To: <599D6D290200007800172726@prv-mh.provo.novell.com>

Hi Jan,

Thanks for reviewing my patch.

2017-08-23 17:55 GMT+08:00 Jan Beulich <JBeulich@suse.com>:
>>>> On 22.08.17 at 20:08, <blackskygg@gmail.com> wrote:
>> The original xsm_map_gmfn_foregin policy checks if source domain has the proper
>> privileges over the target domain. Under this policy, it's not allowed if a Dom0
>> wants to map pages from one DomU to another, this restricts some useful yet not
>> dangerous usages of the API, such as sharing pages among DomU's by calling
>> XENMEM_add_to_physmap from Dom0.
>>
>> Change the policy to: IIF current domain has the proper privilege on the
>> target domain and source domain, grant the access.
>
> You say "and here", yet ...
>
>> --- a/xen/include/xsm/dummy.h
>> +++ b/xen/include/xsm/dummy.h
>> @@ -525,10 +525,12 @@ static XSM_INLINE int xsm_remove_from_physmap(XSM_DEFAULT_ARG struct domain *d1,
>>      return xsm_default_action(action, d1, d2);
>>  }
>>
>> -static XSM_INLINE int xsm_map_gmfn_foreign(XSM_DEFAULT_ARG struct domain *d, struct domain *t)
>> +static XSM_INLINE int xsm_map_gmfn_foreign(XSM_DEFAULT_ARG struct domain *cd,
>> +                                           struct domain *d, struct domain *t)
>>  {
>>      XSM_ASSERT_ACTION(XSM_TARGET);
>> -    return xsm_default_action(action, d, t);
>> +    return xsm_default_action(action, cd, d) ||
>> +        xsm_default_action(action, cd, t);
>>  }
>
> ... you use "or" here and ...

This might be confusing. But think of returning 0 as "allowed", the
only condition where this
statement returns a 0 is when both calls return 0 -- so it's actually
an "and". (Think of de-morgan's law.)

But as Stefano has pointed out, I should preserve the error code.
And as Daniel has pointed out, I should also check if d and t can share memory.

>
>> --- a/xen/xsm/flask/hooks.c
>> +++ b/xen/xsm/flask/hooks.c
>> @@ -1165,9 +1165,11 @@ static int flask_remove_from_physmap(struct domain *d1, struct domain *d2)
>>      return domain_has_perm(d1, d2, SECCLASS_MMU, MMU__PHYSMAP);
>>  }
>>
>> -static int flask_map_gmfn_foreign(struct domain *d, struct domain *t)
>> +static int flask_map_gmfn_foreign(struct domain *cd,
>> +                                  struct domain *d, struct domain *t)
>>  {
>> -    return domain_has_perm(d, t, SECCLASS_MMU, MMU__MAP_READ | MMU__MAP_WRITE);
>> +    return domain_has_perm(cd, d, SECCLASS_MMU, MMU__MAP_READ | MMU__MAP_WRITE) ||
>> +        domain_has_perm(cd, t, SECCLASS_MMU, MMU__MAP_READ | MMU__MAP_WRITE);
>>  }
>
> ... here. A domain can't have XSM_TARGET permission over two
> other domains, so what you want to do here can't work at all,
> afaict.

I agree with what Stefano has said below.

Cheers,

Zhongze Liu.

>
> Jan
>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-08-24  0:51 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22 18:08 [PATCH 0/6] Allow setting up shared memory areas between VMs from xl config files Zhongze Liu
2017-08-22 18:08 ` [PATCH 1/6] libxc: add xc_domain_remove_from_physmap to wrap XENMEM_remove_from_physmap Zhongze Liu
2017-08-23 16:14   ` Wei Liu
2017-08-22 18:08 ` [PATCH 2/6] libxl: introduce a new structure to represent static shared memory regions Zhongze Liu
2017-08-22 20:05   ` Stefano Stabellini
2017-08-23  2:05     ` Zhongze Liu
2017-08-22 18:08 ` [PATCH 3/6] libxl:xl: add parsing code to parse "libxl_static_sshm" from xl config files Zhongze Liu
2017-08-22 20:36   ` Stefano Stabellini
2017-08-23 10:58     ` Julien Grall
2017-08-22 18:08 ` [PATCH 4/6] xsm: flask: change the interface and default policy for xsm_map_gmfn_foregin Zhongze Liu
2017-08-22 19:58   ` Stefano Stabellini
2017-08-23  2:18     ` Zhongze Liu
2017-08-23 15:56       ` Daniel De Graaf
2017-08-23  9:55   ` Jan Beulich
2017-08-23 17:16     ` Stefano Stabellini
2017-08-24  6:32       ` Jan Beulich
2017-08-24  0:51     ` Zhongze Liu [this message]
2017-08-24  6:37       ` Jan Beulich
2017-08-24 11:33         ` Zhongze Liu
2017-08-24 12:39           ` Jan Beulich
2017-08-24 14:30             ` Daniel De Graaf
2017-08-22 18:08 ` [PATCH 5/6] libxl: support mapping static shared memory areas during domain creation Zhongze Liu
2017-08-22 21:42   ` Stefano Stabellini
2017-08-23  2:37     ` Zhongze Liu
2017-08-25 11:05   ` Wei Liu
2017-08-25 12:02     ` Zhongze Liu
2017-08-25 12:09       ` Wei Liu
2017-08-22 18:08 ` [PATCH 6/6] libxl: support unmapping static shared memory areas during domain destruction Zhongze Liu
2017-08-22 21:31   ` Stefano Stabellini
2017-08-23  2:43     ` Zhongze Liu
2017-08-25 11:05   ` Wei Liu

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=CAHrd_jpUPfeks4j7+UE0NkZbzHtUWhcQmV4W_z-t+JB41FJQmA@mail.gmail.com \
    --to=blackskygg@gmail.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=george.dunlap@eu.citrix.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xen.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 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).