Archive-only list for patches
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev,
	Nina Schoetterl-Glausch <nsg@linux.ibm.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	Marc Zyngier <maz@kernel.org>
Subject: [PATCH 6.1 48/85] KVM: arm64: Fix AArch32 register narrowing on userspace write
Date: Thu, 13 Jun 2024 13:35:46 +0200	[thread overview]
Message-ID: <20240613113215.995625025@linuxfoundation.org> (raw)
In-Reply-To: <20240613113214.134806994@linuxfoundation.org>

6.1-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Marc Zyngier <maz@kernel.org>

commit 947051e361d551e0590777080ffc4926190f62f2 upstream.

When userspace writes to one of the core registers, we make
sure to narrow the corresponding GPRs if PSTATE indicates
an AArch32 context.

The code tries to check whether the context is EL0 or EL1 so
that it narrows the correct registers. But it does so by checking
the full PSTATE instead of PSTATE.M.

As a consequence, and if we are restoring an AArch32 EL0 context
in a 64bit guest, and that PSTATE has *any* bit set outside of
PSTATE.M, we narrow *all* registers instead of only the first 15,
destroying the 64bit state.

Obviously, this is not something the guest is likely to enjoy.

Correctly masking PSTATE to only evaluate PSTATE.M fixes it.

Fixes: 90c1f934ed71 ("KVM: arm64: Get rid of the AArch32 register mapping code")
Reported-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Cc: stable@vger.kernel.org
Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Acked-by: Oliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20240524141956.1450304-2-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/arm64/kvm/guest.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/arm64/kvm/guest.c
+++ b/arch/arm64/kvm/guest.c
@@ -270,7 +270,7 @@ static int set_core_reg(struct kvm_vcpu
 	if (*vcpu_cpsr(vcpu) & PSR_MODE32_BIT) {
 		int i, nr_reg;
 
-		switch (*vcpu_cpsr(vcpu)) {
+		switch (*vcpu_cpsr(vcpu) & PSR_AA32_MODE_MASK) {
 		/*
 		 * Either we are dealing with user mode, and only the
 		 * first 15 registers (+ PC) must be narrowed to 32bit.



  parent reply	other threads:[~2024-06-13 12:49 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13 11:34 [PATCH 6.1 00/85] 6.1.94-rc1 review Greg Kroah-Hartman
2024-06-13 11:34 ` [PATCH 6.1 01/85] drm: Check output polling initialized before disabling Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 02/85] drm: Check polling initialized before enabling in drm_helper_probe_single_connector_modes Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 03/85] Bluetooth: btrtl: Add missing MODULE_FIRMWARE declarations Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 04/85] maple_tree: fix allocation in mas_sparse_area() Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 05/85] maple_tree: fix mas_empty_area_rev() null pointer dereference Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 06/85] mmc: core: Do not force a retune before RPMB switch Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 07/85] afs: Dont cross .backup mountpoint from backup volume Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 08/85] riscv: signal: handle syscall restart before get_signal Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 09/85] nilfs2: fix use-after-free of timer for log writer thread Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 10/85] drm/i915/audio: Fix audio time stamp programming for DP Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 11/85] mptcp: avoid some duplicate code in socket option handling Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 12/85] mptcp: cleanup SOL_TCP handling Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 13/85] mptcp: fix full TCP keep-alive support Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 14/85] vxlan: Fix regression when dropping packets due to invalid src addresses Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 15/85] scripts/gdb: fix SB_* constants parsing Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 16/85] f2fs: fix to do sanity check on i_xattr_nid in sanity_check_inode() Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 17/85] media: lgdt3306a: Add a check against null-pointer-def Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 18/85] drm/amdgpu: add error handle to avoid out-of-bounds Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 19/85] bcache: fix variable length array abuse in btree_iter Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 20/85] wifi: rtw89: correct aSIFSTime for 6GHz band Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 21/85] ata: pata_legacy: make legacy_exit() work again Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 22/85] thermal/drivers/qcom/lmh: Check for SCM availability at probe Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 23/85] soc: qcom: rpmh-rsc: Enhance check for VRM in-flight request Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 24/85] ACPI: resource: Do IRQ override on TongFang GXxHRXx and GMxHGxx Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 25/85] arm64: tegra: Correct Tegra132 I2C alias Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 26/85] arm64: dts: qcom: qcs404: fix bluetooth device address Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 27/85] md/raid5: fix deadlock that raid5d() wait for itself to clear MD_SB_CHANGE_PENDING Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 28/85] wifi: rtw89: pci: correct TX resource checking for PCI DMA channel of firmware command Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 29/85] wifi: rtl8xxxu: Fix the TX power of RTL8192CU, RTL8723AU Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 30/85] wifi: rtlwifi: rtl8192de: Fix 5 GHz TX power Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 31/85] wifi: rtlwifi: rtl8192de: Fix low speed with WPA3-SAE Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 32/85] wifi: rtlwifi: rtl8192de: Fix endianness issue in RX path Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 33/85] arm64: dts: hi3798cv200: fix the size of GICR Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 34/85] media: mc: Fix graph walk in media_pipeline_start Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 35/85] media: mc: mark the media devnode as registered from the, start Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 36/85] media: mxl5xx: Move xpt structures off stack Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 37/85] media: v4l2-core: hold videodev_lock until dev reg, finishes Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 38/85] mmc: core: Add mmc_gpiod_set_cd_config() function Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 39/85] mmc: sdhci: Add support for "Tuning Error" interrupts Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 40/85] mmc: sdhci-acpi: Sort DMI quirks alphabetically Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 41/85] mmc: sdhci-acpi: Fix Lenovo Yoga Tablet 2 Pro 1380 sdcard slot not working Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 42/85] mmc: sdhci-acpi: Disable write protect detection on Toshiba WT10-A Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 43/85] mmc: sdhci-acpi: Add quirk to enable pull-up on the card-detect GPIO on Asus T100TA Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 44/85] fbdev: savage: Handle err return when savagefb_check_var failed Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 45/85] drm/amdgpu/atomfirmware: add intergrated info v2.3 table Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 46/85] 9p: add missing locking around taking dentry fid list Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 47/85] drm/amd: Fix shutdown (again) on some SMU v13.0.4/11 platforms Greg Kroah-Hartman
2024-06-13 11:35 ` Greg Kroah-Hartman [this message]
2024-06-13 11:35 ` [PATCH 6.1 49/85] KVM: arm64: Allow AArch32 PSTATE.M to be restored as System mode Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 50/85] KVM: arm64: AArch32: Fix spurious trapping of conditional instructions Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 51/85] crypto: ecdsa - Fix module auto-load on add-key Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 52/85] crypto: ecrdsa - Fix module auto-load on add_key Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 53/85] crypto: qat - Fix ADF_DEV_RESET_SYNC memory leak Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 54/85] mm: fix race between __split_huge_pmd_locked() and GUP-fast Greg Kroah-Hartman
2024-06-24  8:39   ` Ryan Roberts
2024-06-13 11:35 ` [PATCH 6.1 55/85] scsi: core: Handle devices which return an unusually large VPD page count Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 56/85] net/ipv6: Fix route deleting failure when metric equals 0 Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 57/85] net/9p: fix uninit-value in p9_client_rpc() Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 58/85] kmsan: do not wipe out origin when doing partial unpoisoning Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 59/85] cpufreq: amd-pstate: Fix the inconsistency in max frequency units Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 60/85] intel_th: pci: Add Meteor Lake-S CPU support Greg Kroah-Hartman
2024-06-13 11:35 ` [PATCH 6.1 61/85] sparc64: Fix number of online CPUs Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 62/85] mm/cma: drop incorrect alignment check in cma_init_reserved_mem Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 63/85] mm/hugetlb: pass correct order_per_bit to cma_declare_contiguous_nid Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 64/85] watchdog: rti_wdt: Set min_hw_heartbeat_ms to accommodate a safety margin Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 65/85] kdb: Fix buffer overflow during tab-complete Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 66/85] kdb: Use format-strings rather than \0 injection in kdb_read() Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 67/85] kdb: Fix console handling when editing and tab-completing commands Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 68/85] kdb: Merge identical case statements in kdb_read() Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 69/85] kdb: Use format-specifiers rather than memset() for padding " Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 70/85] net: fix __dst_negative_advice() race Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 71/85] sparc: move struct termio to asm/termios.h Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 72/85] ext4: set type of ac_groups_linear_remaining to __u32 to avoid overflow Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 73/85] ext4: fix mb_cache_entrys e_refcnt leak in ext4_xattr_block_cache_find() Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 74/85] parisc: Define HAVE_ARCH_HUGETLB_UNMAPPED_AREA Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 75/85] parisc: Define sigset_t in parisc uapi header Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 76/85] s390/ap: Fix crash in AP internal function modify_bitmap() Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 77/85] s390/cpacf: Split and rework cpacf query functions Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 78/85] s390/cpacf: Make use of invalid opcode produce a link error Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 79/85] i3c: master: svc: fix invalidate IBI type and miss call client IBI handler Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 80/85] EDAC/igen6: Convert PCIBIOS_* return codes to errnos Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 81/85] nfs: fix undefined behavior in nfs_block_bits() Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 82/85] NFS: Fix READ_PLUS when server doesnt support OP_READ_PLUS Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 83/85] btrfs: fix crash on racing fsync and size-extending write into prealloc Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 84/85] powerpc/bpf: enforce full ordering for ATOMIC operations with BPF_FETCH Greg Kroah-Hartman
2024-06-13 11:36 ` [PATCH 6.1 85/85] smb: client: fix deadlock in smb2_find_smb_tcon() Greg Kroah-Hartman
2024-06-13 16:49 ` [PATCH 6.1 00/85] 6.1.94-rc1 review SeongJae Park
2024-06-13 17:43 ` Guenter Roeck
2024-06-15 11:09   ` Greg Kroah-Hartman
2024-06-14  9:35 ` Pavel Machek
2024-06-14 10:17 ` Naresh Kamboju
2024-06-14 12:00 ` Ron Economos
2024-06-14 14:14 ` Mark Brown
2024-06-14 17:03 ` Jon Hunter
2024-06-14 23:21 ` Peter Schneider
2024-06-15  2:09 ` Shuah Khan
2024-06-15 13:19 ` Mateusz Jończyk
2024-06-16 13:18 ` Florian Fainelli

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=20240613113215.995625025@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=maz@kernel.org \
    --cc=nsg@linux.ibm.com \
    --cc=oliver.upton@linux.dev \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.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