All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Ian Jackson <iwj@xenproject.org>, Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>
Subject: [PATCH 9/9] gnttab: don't silently truncate GFNs in compat setup-table handling
Date: Thu, 26 Aug 2021 12:15:10 +0200	[thread overview]
Message-ID: <c3f4d5ce-6ac8-1d1c-eed0-704354f8a5f7@suse.com> (raw)
In-Reply-To: <eb7bbd51-1da3-9a7f-27c7-49dea1a41488@suse.com>

Returning back truncated frame numbers is unhelpful: Quite likely
they're not owned by the domain (if it's PV), or we may misguide the
guest into writing grant entries into a page that it actually uses for
other purposes.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
RFC: Arguably in the 32-bit PV case it may be necessary to instead put
     in place an explicit address restriction when allocating
     ->shared_raw[N]. This is currently implicit by alloc_xenheap_page()
     only returning memory covered by the direct-map.

--- a/xen/common/compat/grant_table.c
+++ b/xen/common/compat/grant_table.c
@@ -175,8 +175,15 @@ int compat_grant_table_op(unsigned int c
                                  i < (_s_)->nr_frames; ++i ) \
                     { \
                         compat_pfn_t frame = (_s_)->frame_list.p[i]; \
-                        if ( __copy_to_compat_offset((_d_)->frame_list, \
-                                                     i, &frame, 1) ) \
+                        if ( frame != (_s_)->frame_list.p[i] ) \
+                        { \
+                            if ( VALID_M2P((_s_)->frame_list.p[i]) ) \
+                                (_s_)->status = GNTST_address_too_big; \
+                            else \
+                                frame |= 0x80000000U;\
+                        } \
+                        else if ( __copy_to_compat_offset((_d_)->frame_list, \
+                                                          i, &frame, 1) ) \
                             (_s_)->status = GNTST_bad_virt_addr; \
                     } \
                 } while (0)



  parent reply	other threads:[~2021-08-26 10:15 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26 10:06 [PATCH 0/9] gnttab: further work from XSA-380 / -382 context Jan Beulich
2021-08-26 10:09 ` [PATCH 1/9] gnttab: defer allocation of maptrack frames table Jan Beulich
2021-09-06 13:13   ` Julien Grall
2021-09-06 13:29     ` Jan Beulich
2021-09-06 13:33       ` Julien Grall
2021-09-06 13:58         ` Jan Beulich
2021-09-06 14:05   ` Andrew Cooper
2021-09-06 14:43     ` Jan Beulich
2021-08-26 10:11 ` [PATCH 2/9] gnttab: drop a redundant expression from gnttab_release_mappings() Jan Beulich
2021-09-06 13:15   ` Julien Grall
2021-08-26 10:12 ` [PATCH 3/9] gnttab: fold recurring is_iomem_page() Jan Beulich
2021-09-06 13:35   ` Julien Grall
2021-09-06 14:02     ` Jan Beulich
2021-08-26 10:13 ` [PATCH 4/9] gnttab: drop GNTMAP_can_fail Jan Beulich
2021-08-26 11:45   ` Andrew Cooper
2021-08-26 13:03     ` Jan Beulich
2021-08-26 13:13       ` Andrew Cooper
2021-08-26 10:13 ` [PATCH 5/9] gnttab: defer allocation of status frame tracking array Jan Beulich
2021-08-26 10:13 ` [PATCH 6/9] gnttab: check handle early in gnttab_get_status_frames() Jan Beulich
2021-09-06 13:41   ` Julien Grall
2021-08-26 10:14 ` [PATCH 7/9] gnttab: no need to translate handle for gnttab_get_status_frames() Jan Beulich
2022-10-07 18:24   ` Andrew Cooper
2021-08-26 10:14 ` [PATCH 8/9] gnttab: bail from GFN-storing loops early in case of error Jan Beulich
2022-10-07 19:36   ` Andrew Cooper
2022-10-10  9:30     ` Jan Beulich
2021-08-26 10:15 ` Jan Beulich [this message]
2022-10-07 19:57   ` [PATCH 9/9] gnttab: don't silently truncate GFNs in compat setup-table handling Andrew Cooper
2022-10-10  8:46     ` Jan Beulich
2022-01-05  7:42 ` Ping: [PATCH 0/9] gnttab: further work from XSA-380 / -382 context Jan Beulich
2022-10-07 13:49 ` Jan Beulich
2022-10-07 18:09   ` Andrew Cooper

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=c3f4d5ce-6ac8-1d1c-eed0-704354f8a5f7@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --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.