linux/arch/powerpc
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
..
boot powerpc: dts: turris1x.dts: Fix PCIe MEM size for pci2 node 2023-07-03 16:26:51 +10:00
configs arch/*/configs/*defconfig: Replace AUTOFS4_FS by AUTOFS_FS 2023-07-29 14:08:22 -07:00
crypto powerpc/crypto: Add gitignore for generated P10 AES/GCM .S files 2023-07-17 13:52:46 +10:00
include powerpc/40x: Remove stale PTE_ATOMIC_UPDATES macro 2023-11-20 11:57:16 +01:00
kernel powerpc: Hide empty pt_regs at base of the stack 2023-11-20 11:57:16 +01:00
kexec powerpc/kexec_file: print error string on usable memory property update failure 2023-02-15 23:14:06 +11:00
kvm powerpc: Don't include lppaca.h in paca.h 2023-09-13 09:53:32 +02:00
lib powerpc/qspinlock: Fix stale propagated yield_cpu 2023-10-25 12:16:29 +02:00
math-emu powerpc/math-emu: Inhibit W=1 warnings 2022-09-08 11:11:18 +10:00
mm powerpc/mm: Fix boot crash with FLATMEM 2023-11-08 14:09:03 +01:00
net powerpc/bpf: populate extable entries only during the last pass 2023-05-15 15:40:31 +10:00
perf powerpc/perf: Fix disabling BHRB and instruction sampling 2023-11-28 17:14:58 +00:00
platforms powerpc/powernv: Fix fortify source warnings in opal-prd.c 2023-11-28 17:15:19 +00:00
purgatory powerpc/purgatory: remove PGO flags 2023-06-12 11:31:50 -07:00
sysdev powerpc/xive: Fix endian conversion size 2023-11-20 11:57:16 +01:00
tools powerpc/64: Use -mprofile-kernel for big endian ELFv2 kernels 2023-06-14 12:46:42 +10:00
xmon powerpc: Don't include lppaca.h in paca.h 2023-09-13 09:53:32 +02:00
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kconfig powerpc/mm: Allow ARCH_FORCE_MAX_ORDER up to 12 2023-10-25 12:16:29 +02:00
Kconfig.debug powerpc: allow PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y 2023-07-03 16:07:55 +10:00
Makefile powerpc: remove checks for binutils older than 2.25 2023-06-27 16:59:29 +10:00
Makefile.postlink kbuild: remove --include-dir MAKEFLAG from top Makefile 2023-02-05 18:51:22 +09:00