From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Laszlo Ersek <lersek@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Michael Tsirkin <mtsirkin@redhat.com>
Cc: "Ard Biesheuvel (kernel.org address)" <ardb@kernel.org>,
qemu devel list <qemu-devel@nongnu.org>
Subject: Re: IO port write width clamping differs between TCG and KVM
Date: Wed, 4 Jan 2023 08:23:20 +0100 [thread overview]
Message-ID: <2048fd2c-0c85-bea5-3c0c-5223bedcc252@linaro.org> (raw)
In-Reply-To: <c03e353e-0d7b-6515-d7ac-1cb71e9cc7c9@redhat.com>
Hi Laszlo,
Happy new year!
On 4/1/23 08:04, Laszlo Ersek wrote:
> Adding Michael. The thread started here:
>
> https://lists.gnu.org/archive/html/qemu-devel/2023-01/msg00199.html
>
> More below:
>
> On 1/4/23 07:06, Laszlo Ersek wrote:
>> On 1/3/23 18:42, Laszlo Ersek wrote:
>>> (resending with qemu-devel on CC; sorry!)
>>>
>>> Hi,
>>>
>>> this is with QEMU-7.2.
>>
>> This is a regression. It works fine with QEMU-5.0. The regression has
>> not been fixed since QEMU-7.2, as of master @ 222059a0fccf ("Merge tag
>> 'pull-ppc-20221221' of https://gitlab.com/danielhb/qemu into staging",
>> 2022-12-21).
>>
>> I'm bisecting.
>>
>> (It's a relief that this is a regression. I felt pretty certain that I
>> had tested CPU hotplug with TCG as well!
>>
>> I've picked QEMU-5.0 as the start candidate for my bisection for the
>> following reason: per git-blame, Igor described the modern interface
>> detection steps in commit ae340aa3d2567 (which I reviewed), and the
>> first tag/release to contain that commit was QEMU-5.0. The first QEMU
>> release after Igor and I had worked on this in QEMU and OVMF
>> definitely worked with TCG too, by my account.)
>
> See the bisection log attached.
>
> The first bad commit is:
>
>> commit 5d971f9e672507210e77d020d89e0e89165c8fc9
>> Author: Michael S. Tsirkin <mst@redhat.com>
>> Date: Wed Jun 10 09:47:49 2020 -0400
>>
>> memory: Revert "memory: accept mismatching sizes in memory_region_access_valid"
Good, I was going to point at this commit but you were faster :) This
commit has been problematic (because not all code base was ready):
$ git log 5d971f9e67.. | fgrep 5d971f9e67
This was not an issue until commit 5d971f9e67 which reverted
This is particularly useful since commit 5d971f9e67 which reverted
This was not an issue until commit 5d971f9e67 which reverted
was allowed before commit 5d971f9e67 ("memory: Revert "memory: accept
Fixes: 5d971f9e67 ("memory: Revert "memory: accept mismatching
sizes in memory_region_access_valid"")
Commit 5d971f9e6725 ("memory: Revert "memory: accept mismatching sizes
Fixes: 5d971f9e6725 ("memory: Revert "memory: accept mismatching
sizes in memory_region_access_valid")
Fixes: 5d971f9e67 (memory: Revert "memory: accept mismatching sizes
in memory_region_access_valid")
5d971f9e6725 ("memory: Revert "memory: accept mismatching sizes in
memory_region_access_valid"")
Commit 5d971f9e672507210e77d020d89e0e89165c8fc9
See the later commit dba04c3488:
commit dba04c3488c4699f5afe96f66e448b1d447cf3fb
Author: Michael Tokarev <mjt@tls.msk.ru>
Date: Mon Jul 20 19:06:27 2020 +0300
acpi: accept byte and word access to core ACPI registers
All ISA registers should be accessible as bytes, words or dwords
(if wide enough). Fix the access constraints for acpi-pm-evt,
acpi-pm-tmr & acpi-cnt registers.
Fixes: 5d971f9e67 (memory: Revert "memory: accept mismatching sizes
in memory_region_access_valid")
Fixes: afafe4bbe0 (apci: switch cnt to memory api)
Fixes: 77d58b1e47 (apci: switch timer to memory api)
Fixes: b5a7c024d2 (apci: switch evt to memory api)
Buglink:
https://lore.kernel.org/xen-devel/20200630170913.123646-1-anthony.perard@citrix.com/T/
Buglink: https://bugs.debian.org/964793
BugLink: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=964247
BugLink: https://bugs.launchpad.net/bugs/1886318
Reported-By: Simon John <git@the-jedi.co.uk>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Message-Id: <20200720160627.15491-1-mjt@msgid.tls.msk.ru>
Cc: qemu-stable@nongnu.org
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>> Memory API documentation documents valid .min_access_size and .max_access_size
>> fields and explains that any access outside these boundaries is blocked.
>>
>> This is what devices seem to assume.
>>
>> However this is not what the implementation does: it simply
>> ignores the boundaries unless there's an "accepts" callback.
>>
>> Naturally, this breaks a bunch of devices.
>>
>> Revert to the documented behaviour.
>>
>> Devices that want to allow any access can just drop the valid field,
>> or add the impl field to have accesses converted to appropriate
>> length.
>>
>> Cc: qemu-stable@nongnu.org
>> Reviewed-by: Richard Henderson <rth@twiddle.net>
>> Fixes: CVE-2020-13754
>> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1842363
>> Fixes: a014ed07bd5a ("memory: accept mismatching sizes in memory_region_access_valid")
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>> Message-Id: <20200610134731.1514409-1-mst@redhat.com>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>
> First released in QEMU v5.1.0 and v6.0.0 (exact same commit hash in
> both, as v6.0.0 descends of v5.1.0).
>
> Because this is a CVE fix, and also because of the suggestions made in
> the commit message, I think the commit is actually right, and what we
> need to fix is the hotplug register block -- namely the
> "AcpiCpuHotplug_ops" structure in "hw/acpi/cpu_hotplug.c".
Do you see anything running with '-d guest_errors'? (on top of commit
21786c7e59 "softmmu/memory: Log invalid memory accesses", or cherry-pick
it if you are around dba04c3488 "acpi: accept byte and word access to
core ACPI registers").
> However, what I *really* don't understand is why this commit
> (5d971f9e672507210e77d020d89e0e89165c8fc9) makes a difference *only*
> under TCG.
Is it easily reproducible with TCG?
Regards,
Phil.
next prev parent reply other threads:[~2023-01-04 7:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-03 17:42 IO port write width clamping differs between TCG and KVM Laszlo Ersek
2023-01-04 6:06 ` Laszlo Ersek
2023-01-04 6:16 ` Laszlo Ersek
2023-01-04 7:04 ` Laszlo Ersek
2023-01-04 7:23 ` Philippe Mathieu-Daudé [this message]
2023-01-04 10:21 ` Laszlo Ersek
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=2048fd2c-0c85-bea5-3c0c-5223bedcc252@linaro.org \
--to=philmd@linaro.org \
--cc=ardb@kernel.org \
--cc=imammedo@redhat.com \
--cc=lersek@redhat.com \
--cc=mtsirkin@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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).