linux-stable/arch
Michael Ellerman 1f59a2a928 powerpc/powernv: Fix fortify source warnings in opal-prd.c
commit feea65a338 upstream.

As reported by Mahesh & Aneesh, opal_prd_msg_notifier() triggers a
FORTIFY_SOURCE warning:

  memcpy: detected field-spanning write (size 32) of single field "&item->msg" at arch/powerpc/platforms/powernv/opal-prd.c:355 (size 4)
  WARNING: CPU: 9 PID: 660 at arch/powerpc/platforms/powernv/opal-prd.c:355 opal_prd_msg_notifier+0x174/0x188 [opal_prd]
  NIP opal_prd_msg_notifier+0x174/0x188 [opal_prd]
  LR  opal_prd_msg_notifier+0x170/0x188 [opal_prd]
  Call Trace:
    opal_prd_msg_notifier+0x170/0x188 [opal_prd] (unreliable)
    notifier_call_chain+0xc0/0x1b0
    atomic_notifier_call_chain+0x2c/0x40
    opal_message_notify+0xf4/0x2c0

This happens because the copy is targeting item->msg, which is only 4
bytes in size, even though the enclosing item was allocated with extra
space following the msg.

To fix the warning define struct opal_prd_msg with a union of the header
and a flex array, and have the memcpy target the flex array.

Reported-by: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Reported-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Tested-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Reviewed-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230821142820.497107-1-mpe@ellerman.id.au
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:15:19 +00:00
..
alpha Kbuild fixes for v6.5 (2nd) 2023-08-13 08:56:24 -07:00
arc ARC: atomics: Add compiler barrier to atomic operations... 2023-09-19 12:30:22 +02:00
arm ARM: 9320/1: fix stack depot IRQ stack filter 2023-11-28 17:14:47 +00:00
arm64 arm64: dts: qcom: ipq6018: Fix tcsr_mutex register size 2023-11-28 17:15:06 +00:00
csky arch/csky patches for 6.5 2023-07-01 21:12:32 -07:00
hexagon Merge branch 'expand-stack' 2023-06-28 20:35:21 -07:00
ia64 locking: remove spin_lock_prefetch 2023-08-12 09:18:47 -07:00
loongarch LoongArch: Mark __percpu functions as always inline 2023-11-28 17:15:14 +00:00
m68k m68k: Fix invalid .section syntax 2023-07-24 14:50:02 +02:00
microblaze slab updates for 6.5 2023-06-29 16:34:12 -07:00
mips MIPS: Alchemy: only build mmc support helpers if au1xmmc is enabled 2023-10-06 13:16:01 +02:00
nios2 slab updates for 6.5 2023-06-29 16:34:12 -07:00
openrisc OpenRISC fix for 6.5 2023-07-12 16:28:53 -07:00
parisc parisc/pgtable: Do not drop upper 5 address bits of physical address 2023-11-28 17:15:10 +00:00
powerpc powerpc/powernv: Fix fortify source warnings in opal-prd.c 2023-11-28 17:15:19 +00:00
riscv riscv: kprobes: allow writing to x0 2023-11-28 17:15:15 +00:00
s390 s390/cmma: fix detection of DAT pages 2023-11-28 17:15:08 +00:00
sh sh: bios: Revive earlyprintk support 2023-11-20 11:57:10 +01:00
sparc sparc32: fix a braino in fault handling in csum_and_copy_..._user() 2023-11-02 09:36:59 +01:00
um um: virt-pci: fix missing declaration warning 2023-09-13 09:53:48 +02:00
x86 KVM: x86: Fix lapic timer interrupt lost after loading a snapshot. 2023-11-28 17:15:00 +00:00
xtensa xtensa: boot/lib: fix function prototypes 2023-10-06 13:16:04 +02:00
.gitignore
Kconfig cpu/SMT: Create topology_smt_thread_allowed() 2023-11-20 11:56:44 +01:00