All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Christophe Fergeau <cfergeau@redhat.com>
Cc: Eric Blake <eblake@redhat.com>,
	qemu-devel@nongnu.org, qemu-stable@nongnu.org,
	"Richard W. M. Jones" <rjones@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] json: Fix % handling when not interpolating
Date: Thu, 24 Jan 2019 10:35:52 +0100	[thread overview]
Message-ID: <87munqieiv.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <87o98sii5b.fsf@dusky.pond.sub.org> (Markus Armbruster's message of "Mon, 07 Jan 2019 16:47:44 +0100")

Markus Armbruster <armbru@redhat.com> writes:

> Eric Blake <eblake@redhat.com> writes:
>
>> On 1/2/19 12:01 PM, Christophe Fergeau wrote:
>>> Adding Markus to cc: list, I forgot to do it when sending the patch.
>>
>> Also worth backporting via qemu-stable, now in cc.
>>
>>> 
>>> Christophe
>>> 
>>> On Wed, Jan 02, 2019 at 03:05:35PM +0100, Christophe Fergeau wrote:
>>>> commit 8bca4613 added support for %% in json strings when interpolating,
>>>> but in doing so, this broke handling of % when not interpolating as the
>>>> '%' is skipped in both cases.
>>>> This commit ensures we only try to handle %% when interpolating.
>
> Impact?
>
> If you're unable to assess, could you give us at least a reproducer?
>
>>>> Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
>>>> ---
>>>>  qobject/json-parser.c | 10 ++++++----
>>>>  tests/check-qjson.c   |  5 +++++
>>>>  2 files changed, 11 insertions(+), 4 deletions(-)
>>>>
>>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>
> Patch looks good to me, but I'd like us to improve the commit message.

Let me try:

    json: Fix % handling when not interpolating

    Commit 8bca4613 added support for %% in json strings when interpolating,
    but in doing so broke handling of % when not interpolating.

    When parse_string() is fed a string token containing '%', it skips the
    '%' regardless of ctxt->ap, i.e. even it's not interpolating.  If the
    '%' is the string's last character, it fails an assertion.  Else, it
    "merely" swallows the '%'.

    Fix parse_string() to handle '%' specially only when interpolating.

    To gauge the bug's impact, let's review non-interpolating users of this
    parser, i.e. code passing NULL context to json_message_parser_init():

    * tests/check-qjson.c, tests/test-qobject-input-visitor.c,
      tests/test-visitor-serialization.c

      Plenty of tests, but we still failed to cover the buggy case.

    * monitor.c: QMP input

    * qga/main.c: QGA input

    * qobject_from_json():

      - qobject-input-visitor.c: JSON command line option arguments of
        -display and -blockdev

        Reproducer: -blockdev '{"%"}'

      - block.c: JSON pseudo-filenames starting with "json:"

        Reproducer: https://bugzilla.redhat.com/show_bug.cgi?id=1668244#c3

      - block/rbd.c: JSON key pairs

        Pseudo-filenames starting with "rbd:".

    Command line, QMP and QGA input are trusted.

    Filenames are trusted when they come from command line, QMP or HMP.
    They are untrusted when they come from from image file headers.
    Example: QCOW2 backing file name.  Note that this is *not* the security
    boundary between host and guest.  It's the boundary between host and an
    image file from an untrusted source.

    Neither failing an assertion nor skipping a character in a filename of
    your choice looks exploitable.  Note that we don't support compiling
    with NDEBUG.

    Fixes: 8bca4613e6cddd948895b8db3def05950463495b
    Cc: qemu-stable@nongnu.org

Comments?

  parent reply	other threads:[~2019-01-24  9:36 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-02 14:05 [Qemu-devel] [PATCH] json: Fix % handling when not interpolating Christophe Fergeau
2019-01-02 18:01 ` Christophe Fergeau
2019-01-02 22:08   ` Eric Blake
2019-01-07 15:47     ` Markus Armbruster
2019-01-07 16:26       ` Eric Blake
2019-01-07 16:36       ` Christophe Fergeau
2019-01-08 10:36         ` Markus Armbruster
2019-01-09 13:06           ` Max Reitz
2019-01-09 14:32             ` Markus Armbruster
2019-01-09 14:41               ` Max Reitz
2019-01-09 16:20                 ` Markus Armbruster
2019-01-09 16:29                   ` Max Reitz
2019-01-09 14:49               ` Daniel P. Berrangé
2019-01-09 15:02                 ` Max Reitz
2019-01-09 16:55                   ` Daniel P. Berrangé
2019-01-10  9:30                     ` Markus Armbruster
2019-01-22 11:18       ` Richard W.M. Jones
2019-01-24  9:35       ` Markus Armbruster [this message]
2019-01-24 12:39         ` Christophe Fergeau
2019-01-24 18:13         ` Eric Blake
2019-01-24 18:29           ` Markus Armbruster
2019-01-24 19:55             ` Eric Blake
2019-01-22 11:21 ` Richard W.M. Jones
2019-01-24 14:37 ` Markus Armbruster

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=87munqieiv.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=cfergeau@redhat.com \
    --cc=eblake@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=rjones@redhat.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 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.