xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: wei.liu2@citrix.com, xen-devel@lists.xensource.com,
	Ian.Jackson@eu.citrix.com
Subject: Re: [PATCH v3 1/6] libxl: allow /local/domain/$LIBXL_TOOLSTACK_DOMID/device-model/$DOMID to be written by $DOMID
Date: Fri, 3 Jul 2015 15:37:11 +0100	[thread overview]
Message-ID: <1435934231.9447.140.camel@citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1506301535570.4360@kaball.uk.xensource.com>

On Tue, 2015-06-30 at 16:00 +0100, Stefano Stabellini wrote:
> When I made this change, I gave a careful look both at the libxl side
> and the QEMU side. Indeed I would appreciate a second pair of eyes on
> this. These are my observations:

I think the request for secondary close review and more importantly
these observations (which == a rationale about why this is safe) deserve
top billing in the commit message.

IMO any commit which deliberately relaxes some security cordon should
have as much information and analysis as possible about why this is OK
to do prominently in the logs. Both so that we can tell that due
diligence has been done and so that we can look back in six months and
see what we thought the security properties of this change were.

> tools/libxl/libxl_dom.c:libxl__toolstack_save is the crux.
> It calls:
> 
> - libxl__xs_directory on /physmap
> this is safe
> 
> - libxl__xs_read
> if the path is wrong (nothing is there), it returns NULL, and it is
> handled correctly
> 
> - strtoll on the values read
> The values are under guest control but strtoll can handle bad formats.
> strtoll always returns an unsigned long long. In case of errors, it can
> return LLONG_MIN or LLONG_MAX.  libxl__toolstack_save doesn't check for
> conversion errors, but it never uses the returned values anywhere.
> That's OK.  tools/libxl/libxl_dom.c:libxl__toolstack_restore writes back
> the values to xenstore.
> 
> So in case of errors:
> 
> 1) libxl__toolstack_save could return early with an error, if the
> xenstore paths are wrong (nothing is on xenstore)
> 2) libxl__toolstack_restore could write back to xenstore any unsigned
> long long, including LLONG_MIN or LLONG_MAX
> 
> Either way we are fine.
> 
> 
> From the QEMU side, the code is fairly similar and uses strtoll to parse
> the entries. The values are used to avoid memory allocations at restore
> time for memory that has already been allocated (video memory). If the
> values are wrong, QEMU will attempt another memory allocation, failing
> because the maxmem limit has been reached (the infamous maxmem increase
> commit has been reverted).

  reply	other threads:[~2015-07-03 14:37 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-10 10:07 [PATCH v3 0/6] libxl: xs_restrict QEMU Stefano Stabellini
2015-06-10 10:09 ` [PATCH v3 1/6] libxl: allow /local/domain/$LIBXL_TOOLSTACK_DOMID/device-model/$DOMID to be written by $DOMID Stefano Stabellini
2015-06-16 14:52   ` Wei Liu
2015-06-29 17:50     ` Stefano Stabellini
2015-06-25 16:16   ` Ian Campbell
2015-06-29 17:52     ` Stefano Stabellini
2015-06-30  8:49       ` Ian Campbell
2015-06-30 13:49         ` Stefano Stabellini
2015-06-30 14:04           ` Ian Campbell
2015-06-30 15:00             ` Stefano Stabellini
2015-07-03 14:37               ` Ian Campbell [this message]
2015-07-23 17:13                 ` Stefano Stabellini
2015-06-30  9:06       ` Ian Jackson
2015-06-10 10:09 ` [PATCH v3 2/6] libxl: do not add a vkb backend to hvm guests Stefano Stabellini
2015-06-16 14:57   ` Wei Liu
2015-06-16 15:39     ` Stefano Stabellini
2015-06-25 16:19       ` Ian Campbell
2015-06-29 17:59         ` Stefano Stabellini
2015-06-30  8:51           ` Ian Campbell
2015-06-30 11:21             ` Stefano Stabellini
2015-06-30 13:32               ` Ian Campbell
2015-06-30 14:02                 ` Stefano Stabellini
2015-06-30 14:13                   ` Ian Campbell
2015-06-30 20:38                     ` Konrad Rzeszutek Wilk
2015-07-01 10:29                       ` Stefano Stabellini
2015-07-01 10:55                         ` Roger Pau Monné
2015-07-01 10:56                           ` Stefano Stabellini
2015-07-01 11:14                             ` Roger Pau Monné
2015-07-01 11:10                           ` Fabio Fantoni
2015-07-01 18:41                         ` Konrad Rzeszutek Wilk
2015-07-02 11:04                           ` Stefano Stabellini
2015-07-02 14:31                             ` Konrad Rzeszutek Wilk
2015-06-10 10:09 ` [PATCH v3 3/6] [WIP] libxl: xsrestrict QEMU Stefano Stabellini
2015-06-25 16:24   ` Ian Campbell
2015-06-29 18:07     ` Stefano Stabellini
2015-06-30  8:53       ` Ian Campbell
2015-06-30 13:53         ` Stefano Stabellini
2015-06-10 10:09 ` [PATCH v3 4/6] libxl: change xs path for QEMU Stefano Stabellini
2015-06-25 16:21   ` Ian Campbell
2015-06-29 18:26     ` Stefano Stabellini
2015-06-10 10:09 ` [PATCH v3 5/6] libxl: change qdisk-backend-pid path on xenstore Stefano Stabellini
2015-06-10 10:09 ` [PATCH v3 6/6] libxl: spawns two QEMUs for HVM guests Stefano Stabellini

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=1435934231.9447.140.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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).