From: Paul Durrant <xadimgnik@gmail.com>
To: "'Andrew Cooper'" <andrew.cooper3@citrix.com>,
"'Xen-devel'" <xen-devel@lists.xenproject.org>
Cc: "'Jan Beulich'" <JBeulich@suse.com>,
"'Roger Pau Monné'" <roger.pau@citrix.com>,
"'Wei Liu'" <wl@xen.org>,
"'Tamas K Lengyel'" <tamas@tklengyel.com>
Subject: RE: [PATCH v2] x86/mm: Short circuit damage from "fishy" ref/typecount failure
Date: Tue, 19 Jan 2021 12:45:31 -0000 [thread overview]
Message-ID: <010d01d6ee60$f958b620$ec0a2260$@xen.org> (raw)
In-Reply-To: <20210119122756.27772-1-andrew.cooper3@citrix.com>
> -----Original Message-----
> From: Andrew Cooper <andrew.cooper3@citrix.com>
> Sent: 19 January 2021 12:28
> To: Xen-devel <xen-devel@lists.xenproject.org>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>; Jan Beulich <JBeulich@suse.com>; Roger Pau Monné
> <roger.pau@citrix.com>; Wei Liu <wl@xen.org>; Paul Durrant <paul@xen.org>; Tamas K Lengyel
> <tamas@tklengyel.com>
> Subject: [PATCH v2] x86/mm: Short circuit damage from "fishy" ref/typecount failure
>
> This code has been copied in 3 places, but it is problematic.
>
> All cases will hit a BUG() later in domain teardown, when a the missing
> type/count reference is underflowed.
>
> Don't complicated the logic by leaving a totally unqualified domain crash, and
> a timebomb which will be triggered by the toolstack at a slightly later, and
> seemingly unrelated, point.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> CC: Wei Liu <wl@xen.org>
> CC: Paul Durrant <paul@xen.org>
> CC: Tamas K Lengyel <tamas@tklengyel.com>
>
> v2:
> * Reword the commit message.
> * Switch BUG() to BUG_ON() to further reduce code volume.
> ---
> xen/arch/x86/hvm/ioreq.c | 11 ++---------
> xen/arch/x86/hvm/vmx/vmx.c | 11 ++---------
> xen/arch/x86/mm/mem_paging.c | 17 ++++-------------
> 3 files changed, 8 insertions(+), 31 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c
> index 1cc27df87f..0c38cfa151 100644
> --- a/xen/arch/x86/hvm/ioreq.c
> +++ b/xen/arch/x86/hvm/ioreq.c
> @@ -366,15 +366,8 @@ static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server *s, bool buf)
> if ( !page )
> return -ENOMEM;
>
> - if ( !get_page_and_type(page, s->target, PGT_writable_page) )
> - {
> - /*
> - * The domain can't possibly know about this page yet, so failure
> - * here is a clear indication of something fishy going on.
> - */
> - domain_crash(s->emulator);
> - return -ENODATA;
> - }
> + /* Domain can't know about this page yet - something fishy going on. */
> + BUG_ON(!get_page_and_type(page, s->target, PGT_writable_page));
>
> iorp->va = __map_domain_page_global(page);
> if ( !iorp->va )
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index 2d4475ee3d..8e438cb781 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -3042,15 +3042,8 @@ static int vmx_alloc_vlapic_mapping(struct domain *d)
> if ( !pg )
> return -ENOMEM;
>
> - if ( !get_page_and_type(pg, d, PGT_writable_page) )
> - {
> - /*
> - * The domain can't possibly know about this page yet, so failure
> - * here is a clear indication of something fishy going on.
> - */
> - domain_crash(d);
> - return -ENODATA;
> - }
> + /* Domain can't know about this page yet - something fishy going on. */
> + BUG_ON(!get_page_and_type(page, s->target, PGT_writable_page));
Does this compile?
s/page/pg
s/s->target/d
...and similar below is needed AFAICT.
Paul
>
> mfn = page_to_mfn(pg);
> clear_domain_page(mfn);
> diff --git a/xen/arch/x86/mm/mem_paging.c b/xen/arch/x86/mm/mem_paging.c
> index 01281f786e..6e90019e76 100644
> --- a/xen/arch/x86/mm/mem_paging.c
> +++ b/xen/arch/x86/mm/mem_paging.c
> @@ -379,19 +379,10 @@ static int prepare(struct domain *d, gfn_t gfn,
> page = alloc_domheap_page(d, 0);
> if ( unlikely(page == NULL) )
> goto out;
> - if ( unlikely(!get_page(page, d)) )
> - {
> - /*
> - * The domain can't possibly know about this page yet, so failure
> - * here is a clear indication of something fishy going on.
> - */
> - gprintk(XENLOG_ERR,
> - "%pd: fresh page for GFN %"PRI_gfn" in unexpected state\n",
> - d, gfn_x(gfn));
> - domain_crash(d);
> - page = NULL;
> - goto out;
> - }
> +
> + /* Domain can't know about this page yet - something fishy going on. */
> + BUG_ON(!get_page(page, s->target));
> +
> mfn = page_to_mfn(page);
> page_extant = 0;
>
> --
> 2.11.0
next prev parent reply other threads:[~2021-01-19 12:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 9:41 [PATCH] x86/mm: Remove cascade damage from "fishy" ref/typecount failure Andrew Cooper
2021-01-19 11:34 ` Andrew Cooper
2021-01-19 12:27 ` [PATCH v2] x86/mm: Short circuit " Andrew Cooper
2021-01-19 12:45 ` Paul Durrant [this message]
2021-01-19 13:00 ` Andrew Cooper
2021-01-19 13:02 ` [PATCH v3] " Andrew Cooper
2021-01-19 13:06 ` Paul Durrant
2021-01-19 16:48 ` Jan Beulich
2021-01-19 18:09 ` Andrew Cooper
2021-01-20 8:06 ` Jan Beulich
2021-01-25 17:59 ` Andrew Cooper
2021-01-26 10:48 ` Jan Beulich
2021-01-28 14:48 ` Jan Beulich
2021-01-29 11:29 ` Jan Beulich
2021-01-29 16:17 ` Andrew Cooper
2021-01-29 16:31 ` Jan Beulich
2021-01-29 17:17 ` Andrew Cooper
2021-02-01 12:50 ` Jan Beulich
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='010d01d6ee60$f958b620$ec0a2260$@xen.org' \
--to=xadimgnik@gmail.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=paul@xen.org \
--cc=roger.pau@citrix.com \
--cc=tamas@tklengyel.com \
--cc=wl@xen.org \
--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.