From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
xen-devel <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Wei Liu <wei.liu2@citrix.com>,
George Dunlap <George.Dunlap@eu.citrix.com>,
Tim Deegan <tim@xen.org>, Ian Jackson <Ian.Jackson@eu.citrix.com>,
tamas@tklengyel.com
Subject: Re: [PATCH] x86/memshr: properly check grant references
Date: Mon, 14 Nov 2016 11:56:48 +0000 [thread overview]
Message-ID: <06064a69-7cf4-366c-889c-22f0226eb51a@citrix.com> (raw)
In-Reply-To: <5829A143020000780011E59D@prv-mh.provo.novell.com>
On 14/11/16 10:34, Jan Beulich wrote:
> --- a/xen/common/grant_table.c
> +++ b/xen/common/grant_table.c
> @@ -3438,6 +3438,53 @@ void grant_table_init_vcpu(struct vcpu *
> v->maptrack_tail = MAPTRACK_TAIL;
> }
>
> +#ifdef CONFIG_HAS_MEM_SHARING
> +int mem_sharing_gref_to_gfn(struct grant_table *gt, grant_ref_t ref,
> + gfn_t *gfn, uint16_t *status)
> +{
> + int rc = 0;
> + uint16_t flags = 0;
> +
> + grant_read_lock(gt);
> +
> + if ( gt->gt_version < 1 )
> + rc = -EINVAL;
> + else if ( ref >= nr_grant_entries(gt) )
> + rc = -ENOENT;
> + else if ( gt->gt_version == 1 )
> + {
> + const grant_entry_v1_t *sha1 = &shared_entry_v1(gt, ref);
> +
> + flags = sha1->flags;
> + *gfn = _gfn(sha1->frame);
> + }
> + else
> + {
> + const grant_entry_v2_t *sha2 = &shared_entry_v2(gt, ref);
> +
> + flags = sha2->hdr.flags;
> + if ( flags & GTF_sub_page )
> + *gfn = _gfn(sha2->sub_page.frame);
> + else
> + *gfn = _gfn(sha2->full_page.frame);
> + }
> +
> + if ( (flags & GTF_type_mask) != GTF_permit_access )
> + rc = -ENXIO;
This will clobber the EINVAL/ENOENT cases. It wants to be pared with an
!rc &&.
With this fixed, Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
> + else if ( !rc && status )
> + {
> + if ( gt->gt_version == 1 )
> + *status = flags;
> + else
> + *status = status_entry(gt, ref);
> + }
> +
> + grant_read_unlock(gt);
> +
> + return rc;
> +}
> +#endif
> +
> static void gnttab_usage_print(struct domain *rd)
> {
> int first = 1;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-11-14 11:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-14 10:34 [PATCH] x86/memshr: properly check grant references Jan Beulich
2016-11-14 11:56 ` Andrew Cooper [this message]
2016-11-14 12:56 ` Jan Beulich
2016-11-22 10:12 ` Ping: " Jan Beulich
2016-11-22 16:13 ` Tamas K Lengyel
2016-11-22 16:17 ` Jan Beulich
2016-11-22 16:22 ` 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=06064a69-7cf4-366c-889c-22f0226eb51a@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=sstabellini@kernel.org \
--cc=tamas@tklengyel.com \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--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 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).