From: Daniel De Graaf <dgdegra@tycho.nsa.gov>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel@lists.xen.org
Subject: Re: [PATCH 16/18] arch/x86: use XSM hooks for get_pg_owner access checks
Date: Mon, 06 Aug 2012 12:29:31 -0400 [thread overview]
Message-ID: <501FF0EB.1000900@tycho.nsa.gov> (raw)
In-Reply-To: <501FFE560200007800092FBA@nat28.tlf.novell.com>
On 08/06/2012 11:26 AM, Jan Beulich wrote:
>>>> On 06.08.12 at 16:32, Daniel De Graaf <dgdegra@tycho.nsa.gov> wrote:
>> --- a/xen/arch/x86/mm.c
>> +++ b/xen/arch/x86/mm.c
>> @@ -2882,11 +2882,6 @@ static struct domain *get_pg_owner(domid_t domid)
>> pg_owner = rcu_lock_domain(dom_io);
>> break;
>> case DOMID_XEN:
>> - if ( !IS_PRIV(curr) )
>> - {
>> - MEM_LOG("Cannot set foreign dom");
>> - break;
>> - }
>> pg_owner = rcu_lock_domain(dom_xen);
>> break;
>> default:
>> @@ -2895,12 +2890,6 @@ static struct domain *get_pg_owner(domid_t domid)
>> MEM_LOG("Unknown domain '%u'", domid);
>> break;
>> }
>> - if ( !IS_PRIV_FOR(curr, pg_owner) )
>> - {
>> - MEM_LOG("Cannot set foreign dom");
>> - rcu_unlock_domain(pg_owner);
>> - pg_owner = NULL;
>> - }
>> break;
>> }
>>
>> @@ -3008,6 +2997,13 @@ int do_mmuext_op(
>> goto out;
>> }
>>
>> + rc = xsm_mmuext_op(d, pg_owner);
>
> Given the above, this could be
>
> xsm_mmuext_op(dom0, DOMID_{IO,XEN});
>
> yet ...
>
>> + if ( rc )
>> + {
>> + rcu_unlock_domain(pg_owner);
>> + goto out;
>> + }
>> +
>> for ( i = 0; i < count; i++ )
>> {
>> if ( hypercall_preempt_check() )
>> @@ -3483,11 +3479,6 @@ int do_mmu_update(
>> rc = -EINVAL;
>> goto out;
>> }
>> - if ( !IS_PRIV_FOR(d, pt_owner) )
>> - {
>> - rc = -ESRCH;
>> - goto out;
>> - }
>> }
>>
>> if ( (pg_owner = get_pg_owner((uint16_t)foreigndom)) == NULL )
>> @@ -3643,7 +3634,7 @@ int do_mmu_update(
>> mfn = req.ptr >> PAGE_SHIFT;
>> gpfn = req.val;
>>
>> - rc = xsm_mmu_machphys_update(d, mfn);
>> + rc = xsm_mmu_machphys_update(d, pg_owner, mfn);
>> if ( rc )
>> break;
>>
>> --- a/xen/include/xsm/dummy.h
>> +++ b/xen/include/xsm/dummy.h
>> @@ -803,19 +803,35 @@ static XSM_DEFAULT(int, domain_memory_map) (struct domain *d)
>> }
>>
>> static XSM_DEFAULT(int, mmu_normal_update) (struct domain *d, struct domain *t,
>> - struct domain *f, intpte_t fpte)
>> + struct domain *f, intpte_t fpte)
>> {
>> + if ( d != t && !IS_PRIV_FOR(d, t) )
>> + return -EPERM;
>> + if ( d != f && !IS_PRIV_FOR(d, f) )
>> + return -EPERM;
>> return 0;
>> }
>>
>> -static XSM_DEFAULT(int, mmu_machphys_update) (struct domain *d, unsigned long mfn)
>> +static XSM_DEFAULT(int, mmu_machphys_update) (struct domain *d, struct domain *f,
>> + unsigned long mfn)
>> {
>> + if ( d != f && !IS_PRIV_FOR(d, f) )
>> + return -EPERM;
>> + return 0;
>> +}
>> +
>> +static XSM_DEFAULT(int, mmuext_op) (struct domain *d, struct domain *f)
>> +{
>> + if ( d != f && !IS_PRIV_FOR(d, f) )
>> + return -EPERM;
>
> ... Dom0 is neither privileged for DOM_IO nor for DOM_XEN.
Actually, it is. IS_PRIV_FOR returns true for any domain when called from an
IS_PRIV domain.
>
>> return 0;
>> }
>>
>> static XSM_DEFAULT(int, update_va_mapping) (struct domain *d, struct domain *f,
>> l1_pgentry_t pte)
>> {
>> + if ( d != f && !IS_PRIV_FOR(d, f) )
>> + return -EPERM;
>> return 0;
>> }
>>
>
> Didn't check the other cases in any detail.
>
> Jan
>
--
Daniel De Graaf
National Security Agency
next prev parent reply other threads:[~2012-08-06 16:29 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-06 14:32 [PATCH 00/18] RFC: Merge IS_PRIV checks into XSM hooks Daniel De Graaf
2012-08-06 14:32 ` [PATCH 01/18] xsm/flask: remove inherited class attributes Daniel De Graaf
2012-08-06 14:32 ` [PATCH 02/18] xsm/flask: remove unneeded create_sid field Daniel De Graaf
2012-08-06 14:32 ` [PATCH 03/18] xsm/flask: add domain relabel support Daniel De Graaf
2012-08-06 14:32 ` [PATCH 04/18] libxl: introduce XSM relabel on build Daniel De Graaf
2012-08-06 14:32 ` [PATCH 05/18] flask/policy: Add domain relabel example Daniel De Graaf
2012-08-06 14:32 ` [PATCH 06/18] xsm, arch/x86: add distinct XSM hooks for map/unmap Daniel De Graaf
2012-08-06 14:32 ` [PATCH 07/18] arch/x86: add missing XSM checks to XENPF_ commands Daniel De Graaf
2012-08-06 14:57 ` Jan Beulich
2012-08-06 15:06 ` Daniel De Graaf
2012-08-06 14:32 ` [PATCH 08/18] xen: Add DOMID_SELF support to rcu_lock_domain_by_id Daniel De Graaf
2012-08-06 15:07 ` Jan Beulich
2012-08-06 15:19 ` Daniel De Graaf
2012-08-06 15:50 ` Jan Beulich
2012-08-06 16:38 ` Daniel De Graaf
2012-08-07 7:00 ` Jan Beulich
2012-08-06 14:32 ` [PATCH 09/18] xsm/flask: Add checks on the domain performing the set_target operation Daniel De Graaf
2012-08-06 14:32 ` [PATCH 10/18] xsm: Add IS_PRIV checks to dummy XSM module Daniel De Graaf
2012-08-06 14:32 ` [PATCH 11/18] xen: use XSM instead of IS_PRIV where duplicated Daniel De Graaf
2012-08-06 15:18 ` Jan Beulich
2012-08-06 15:25 ` Daniel De Graaf
2012-08-06 15:53 ` Jan Beulich
2012-08-06 14:32 ` [PATCH 12/18] xsm: Add missing domctl and mem_sharing hooks Daniel De Graaf
2012-08-06 18:53 ` Keir Fraser
2012-08-06 19:30 ` Daniel De Graaf
2012-08-06 14:32 ` [PATCH 13/18] tmem: Add access control check Daniel De Graaf
2012-08-06 14:32 ` [PATCH 14/18] xsm: remove unneeded xsm_call macro Daniel De Graaf
2012-08-06 14:32 ` [PATCH 15/18] xsm/flask: add distinct SIDs for self/target access Daniel De Graaf
2012-08-06 14:32 ` [PATCH 16/18] arch/x86: use XSM hooks for get_pg_owner access checks Daniel De Graaf
2012-08-06 15:26 ` Jan Beulich
2012-08-06 16:29 ` Daniel De Graaf [this message]
2012-08-07 6:55 ` Jan Beulich
2012-08-07 13:44 ` Daniel De Graaf
2012-08-07 13:56 ` Jan Beulich
2012-08-06 14:32 ` [PATCH 17/18] xen: Add XSM hook for XENMEM_exchange Daniel De Graaf
2012-08-06 14:32 ` [PATCH 18/18] xen: remove rcu_lock_target_domain_by_id Daniel De Graaf
2012-08-07 5:12 ` [PATCH 00/18] RFC: Merge IS_PRIV checks into XSM hooks Shakeel Butt
2012-08-07 17:46 ` Daniel De Graaf
2012-08-07 18:07 ` Shakeel Butt
2012-08-07 18:06 ` Konrad Rzeszutek Wilk
2012-08-07 18:20 ` Daniel De Graaf
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=501FF0EB.1000900@tycho.nsa.gov \
--to=dgdegra@tycho.nsa.gov \
--cc=JBeulich@suse.com \
--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).