stable.vger.kernel.org archive mirror
 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, Sean Christopherson <seanjc@google.com>
Subject: [PATCH 6.11 054/107] KVM: selftests: Disable strict aliasing
Date: Wed, 20 Nov 2024 13:56:29 +0100	[thread overview]
Message-ID: <20241120125630.895744800@linuxfoundation.org> (raw)
In-Reply-To: <20241120125629.681745345@linuxfoundation.org>

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

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

From: Sean Christopherson <seanjc@google.com>

commit 5b188cc4866aaf712e896f92ac42c7802135e507 upstream.

Disable strict aliasing, as has been done in the kernel proper for decades
(literally since before git history) to fix issues where gcc will optimize
away loads in code that looks 100% correct, but is _technically_ undefined
behavior, and thus can be thrown away by the compiler.

E.g. arm64's vPMU counter access test casts a uint64_t (unsigned long)
pointer to a u64 (unsigned long long) pointer when setting PMCR.N via
u64p_replace_bits(), which gcc-13 detects and optimizes away, i.e. ignores
the result and uses the original PMCR.

The issue is most easily observed by making set_pmcr_n() noinline and
wrapping the call with printf(), e.g. sans comments, for this code:

  printf("orig = %lx, next = %lx, want = %lu\n", pmcr_orig, pmcr, pmcr_n);
  set_pmcr_n(&pmcr, pmcr_n);
  printf("orig = %lx, next = %lx, want = %lu\n", pmcr_orig, pmcr, pmcr_n);

gcc-13 generates:

 0000000000401c90 <set_pmcr_n>:
  401c90:       f9400002        ldr     x2, [x0]
  401c94:       b3751022        bfi     x2, x1, #11, #5
  401c98:       f9000002        str     x2, [x0]
  401c9c:       d65f03c0        ret

 0000000000402660 <test_create_vpmu_vm_with_pmcr_n>:
  402724:       aa1403e3        mov     x3, x20
  402728:       aa1503e2        mov     x2, x21
  40272c:       aa1603e0        mov     x0, x22
  402730:       aa1503e1        mov     x1, x21
  402734:       940060ff        bl      41ab30 <_IO_printf>
  402738:       aa1403e1        mov     x1, x20
  40273c:       910183e0        add     x0, sp, #0x60
  402740:       97fffd54        bl      401c90 <set_pmcr_n>
  402744:       aa1403e3        mov     x3, x20
  402748:       aa1503e2        mov     x2, x21
  40274c:       aa1503e1        mov     x1, x21
  402750:       aa1603e0        mov     x0, x22
  402754:       940060f7        bl      41ab30 <_IO_printf>

with the value stored in [sp + 0x60] ignored by both printf() above and
in the test proper, resulting in a false failure due to vcpu_set_reg()
simply storing the original value, not the intended value.

  $ ./vpmu_counter_access
  Random seed: 0x6b8b4567
  orig = 3040, next = 3040, want = 0
  orig = 3040, next = 3040, want = 0
  ==== Test Assertion Failure ====
    aarch64/vpmu_counter_access.c:505: pmcr_n == get_pmcr_n(pmcr)
    pid=71578 tid=71578 errno=9 - Bad file descriptor
       1        0x400673: run_access_test at vpmu_counter_access.c:522
       2         (inlined by) main at vpmu_counter_access.c:643
       3        0x4132d7: __libc_start_call_main at libc-start.o:0
       4        0x413653: __libc_start_main at ??:0
       5        0x40106f: _start at ??:0
    Failed to update PMCR.N to 0 (received: 6)

Somewhat bizarrely, gcc-11 also exhibits the same behavior, but only if
set_pmcr_n() is marked noinline, whereas gcc-13 fails even if set_pmcr_n()
is inlined in its sole caller.

Cc: stable@vger.kernel.org
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116912
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 tools/testing/selftests/kvm/Makefile |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -235,10 +235,10 @@ CFLAGS += -Wall -Wstrict-prototypes -Wun
 	-Wno-gnu-variable-sized-type-not-at-end -MD -MP -DCONFIG_64BIT \
 	-fno-builtin-memcmp -fno-builtin-memcpy \
 	-fno-builtin-memset -fno-builtin-strnlen \
-	-fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
-	-I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \
-	-I$(<D) -Iinclude/$(ARCH_DIR) -I ../rseq -I.. $(EXTRA_CFLAGS) \
-	$(KHDR_INCLUDES)
+	-fno-stack-protector -fno-PIE -fno-strict-aliasing \
+	-I$(LINUX_TOOL_INCLUDE) -I$(LINUX_TOOL_ARCH_INCLUDE) \
+	-I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -Iinclude/$(ARCH_DIR) \
+	-I ../rseq -I.. $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
 ifeq ($(ARCH),s390)
 	CFLAGS += -march=z10
 endif



  parent reply	other threads:[~2024-11-20 12:58 UTC|newest]

Thread overview: 118+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-20 12:55 [PATCH 6.11 000/107] 6.11.10-rc1 review Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 001/107] netlink: terminate outstanding dump on socket close Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 002/107] sctp: fix possible UAF in sctp_v6_available() Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 003/107] net: vertexcom: mse102x: Fix tx_bytes calculation Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 004/107] drm/rockchip: vop: Fix a dereferenced before check warning Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 005/107] net: fix data-races around sk->sk_forward_alloc Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 006/107] mptcp: error out earlier on disconnect Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 007/107] mptcp: cope racing subflow creation in mptcp_rcv_space_adjust Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 008/107] net/mlx5: Fix msix vectors to respect platform limit Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 009/107] net/mlx5: fs, lock FTE when checking if active Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 010/107] net/mlx5e: kTLS, Fix incorrect page refcounting Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 011/107] net/mlx5e: clear xdp features on non-uplink representors Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 012/107] net/mlx5e: CT: Fix null-ptr-deref in add rule err flow Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 013/107] net/mlx5e: Disable loopback self-test on multi-PF netdev Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 014/107] drm/i915/gsc: ARL-H and ARL-U need a newer GSC FW Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 015/107] virtio/vsock: Fix accept_queue memory leak Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 016/107] vsock: Fix sk_error_queue " Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 017/107] virtio/vsock: Improve MSG_ZEROCOPY error handling Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 018/107] Revert "RDMA/core: Fix ENODEV error for iWARP test over vlan" Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 019/107] drivers: perf: Fix wrong put_cpu() placement Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 020/107] Bluetooth: hci_core: Fix calling mgmt_device_connected Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 021/107] Bluetooth: btintel: Direct exception event to bluetooth stack Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 022/107] drm/panthor: Fix handling of partial GPU mapping of BOs Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 023/107] net: sched: cls_u32: Fix u32s systematic failure to free IDR entries for hnodes Greg Kroah-Hartman
2024-11-20 12:55 ` [PATCH 6.11 024/107] net: phylink: ensure PHY momentary link-fails are handled Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 025/107] samples: pktgen: correct dev to DEV Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 026/107] net: stmmac: dwmac-mediatek: Fix inverted handling of mediatek,mac-wol Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 027/107] net: Make copy_safe_from_sockptr() match documentation Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 028/107] stmmac: dwmac-intel-plat: fix call balance of tx_clk handling routines Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 029/107] drm/vmwgfx: avoid null_ptr_deref in vmw_framebuffer_surface_create_handle Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 030/107] net: ti: icssg-prueth: Fix 1 PPS sync Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 031/107] bonding: add ns target multicast address to slave device Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 032/107] ARM: 9419/1: mm: Fix kernel memory mapping for xip kernels Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 033/107] ARM: fix cacheflush with PAN Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 034/107] tools/mm: fix compile error Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 035/107] Revert "drm/amd/pm: correct the workload setting" Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 036/107] drm/amd/display: Run idle optimizations at end of vblank handler Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 037/107] drm/amd/display: Change some variable name of psr Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 038/107] drm/amd/display: Fix Panel Replay not update screen correctly Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 039/107] x86/CPU/AMD: Clear virtualized VMLOAD/VMSAVE on Zen4 client Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 040/107] x86/mm: Fix a kdump kernel failure on SME system when CONFIG_IMA_KEXEC=y Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 041/107] x86/stackprotector: Work around strict Clang TLS symbol requirements Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 042/107] mm: fix NULL pointer dereference in alloc_pages_bulk_noprof Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 043/107] ocfs2: uncache inode which has failed entering the group Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 044/107] crash, powerpc: default to CRASH_DUMP=n on PPC_BOOK3S_32 Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 045/107] sched/task_stack: fix object_is_on_stack() for KASAN tagged pointers Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 046/107] fs/proc/task_mmu: prevent integer overflow in pagemap_scan_get_args() Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 047/107] mm/mremap: fix address wraparound in move_page_tables() Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 048/107] mm: revert "mm: shmem: fix data-race in shmem_getattr()" Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 049/107] vdpa: solidrun: Fix UB bug with devres Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 050/107] vdpa/mlx5: Fix PA offset with unaligned starting iotlb map Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 051/107] vp_vdpa: fix id_table array not null terminated error Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 052/107] ima: fix buffer overrun in ima_eventdigest_init_common Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 053/107] evm: stop avoidably reading i_writecount in evm_file_release Greg Kroah-Hartman
2024-11-20 12:56 ` Greg Kroah-Hartman [this message]
2024-11-20 12:56 ` [PATCH 6.11 055/107] KVM: nVMX: Treat vpid01 as current if L2 is active, but with VPID disabled Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 056/107] KVM: x86: Unconditionally set irr_pending when updating APICv state Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 057/107] KVM: VMX: Bury Intel PT virtualization (guest/host mode) behind CONFIG_BROKEN Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 058/107] nilfs2: fix null-ptr-deref in block_touch_buffer tracepoint Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 059/107] nommu: pass NULL argument to vma_iter_prealloc() Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 060/107] tpm: Disable TPM on tpm2_create_primary() failure Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 061/107] mm: page_alloc: move mlocked flag clearance into free_pages_prepare() Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 062/107] ALSA: hda/realtek - Fixed Clevo platform headset Mic issue Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 063/107] ALSA: hda/realtek - update set GPIO3 to default for Thinkpad with ALC1318 Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 064/107] ALSA: hda/realtek: fix mute/micmute LEDs for a HP EliteBook 645 G10 Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 065/107] mptcp: update local address flags when setting it Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 066/107] mptcp: hold pm lock when deleting entry Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 067/107] mptcp: pm: use _rcu variant under rcu_read_lock Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 068/107] ocfs2: fix UBSAN warning in ocfs2_verify_volume() Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 069/107] nilfs2: fix null-ptr-deref in block_dirty_buffer tracepoint Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 070/107] LoongArch: Fix early_numa_add_cpu() usage for FDT systems Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 071/107] LoongArch: Disable KASAN if PGDIR_SIZE is too large for cpu_vabits Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 072/107] LoongArch: Add WriteCombine shadow mapping in KASAN Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 073/107] LoongArch: Fix AP booting issue in VM mode Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 074/107] LoongArch: Make KASAN work with 5-level page-tables Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 075/107] selftests: hugetlb_dio: fixup check for initial conditions to skip in the start Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 076/107] Revert "mmc: dw_mmc: Fix IDMAC operation with pages bigger than 4K" Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 077/107] Revert "drm/amd/display: parse umc_info or vram_info based on ASIC" Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 078/107] btrfs: fix incorrect comparison for delayed refs Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 079/107] mailbox: qcom-cpucp: Mark the irq with IRQF_NO_SUSPEND flag Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 080/107] firmware: arm_scmi: Skip opp duplicates Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 081/107] firmware: arm_scmi: Report duplicate opps as firmware bugs Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 082/107] mmc: sunxi-mmc: Fix A100 compatible description Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 083/107] drm/bridge: tc358768: Fix DSI command tx Greg Kroah-Hartman
2024-11-20 12:56 ` [PATCH 6.11 084/107] drm/xe: handle flat ccs during hibernation on igpu Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 085/107] drm/xe/oa: Fix "Missing outer runtime PM protection" warning Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 086/107] pmdomain: imx93-blk-ctrl: correct remove path Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 087/107] pmdomain: arm: Use FLAG_DEV_NAME_FW to ensure unique names Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 088/107] pmdomain: core: Add GENPD_FLAG_DEV_NAME_FW flag Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 089/107] nouveau: fw: sync dma after setup is called Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 090/107] nouveau: handle EBUSY and EAGAIN for GSP aux errors Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 091/107] nouveau/dp: handle retries for AUX CH transfers with GSP Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 092/107] drm/amd: Fix initialization mistake for NBIO 7.7.0 Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 093/107] drm/amdgpu: fix check in gmc_v9_0_get_vm_pte() Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 094/107] drm/amdgpu: Fix video caps for H264 and HEVC encode maximum size Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 095/107] drm/amd/pm: print pp_dpm_mclk in ascending order on SMU v14.0.0 Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 096/107] drm/amdgpu: enable GTT fallback handling for dGPUs only Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 097/107] drm/amdgpu/mes12: correct kiq unmap latency Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 098/107] drm/amd/display: Adjust VSDB parser for replay feature Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 099/107] drm/amd/display: Require minimum VBlank size for stutter optimization Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 100/107] drm/amd/display: Handle dml allocation failure to avoid crash Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 101/107] drm/amd/display: Fix failure to read vram info due to static BP_RESULT Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 102/107] mm: refactor arch_calc_vm_flag_bits() and arm64 MTE handling Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 103/107] drm/xe: Restore system memory GGTT mappings Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 104/107] drm/xe: improve hibernation on igpu Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 105/107] lib/buildid: Fix build ID parsing logic Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 106/107] net: sched: u32: Add test case for systematic hnode IDR leaks Greg Kroah-Hartman
2024-11-20 12:57 ` [PATCH 6.11 107/107] media: dvbdev: fix the logic when DVB_DYNAMIC_MINORS is not set Greg Kroah-Hartman
2024-11-20 16:45 ` [PATCH 6.11 000/107] 6.11.10-rc1 review Mark Brown
2024-11-20 17:02 ` SeongJae Park
2024-11-20 19:18 ` Florian Fainelli
2024-11-20 23:20 ` Shuah Khan
2024-11-21  4:13 ` Ron Economos
2024-11-21  9:32 ` Pavel Machek
2024-11-21 11:38 ` Naresh Kamboju
2024-11-22  0:05 ` Justin Forbes
2024-11-22  6:41 ` Muhammad Usama Anjum
2024-11-22  8:06 ` Jon Hunter

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=20241120125630.895744800@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=patches@lists.linux.dev \
    --cc=seanjc@google.com \
    --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;
as well as URLs for NNTP newsgroup(s).