linux-stable/arch/powerpc
Michael Ellerman feea65a338 powerpc/powernv: Fix fortify source warnings in opal-prd.c
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
2023-08-24 22:33:04 +10:00
..
boot powerpc: dts: turris1x.dts: Fix PCIe MEM size for pci2 node 2023-07-03 16:26:51 +10:00
configs powerpc/configs: Drop CONFIG_IP_NF_TARGET_CLUSTERIP 2023-08-18 17:03:15 +10:00
crypto powerpc/crypto: don't build aes-gcm-p10 by default 2023-08-02 22:22:18 +10:00
include powerpc/64e: Fix circular dependency with CONFIG_SMP disabled 2023-08-23 15:55:21 +10:00
kernel powerpc/85xx: Mark some functions static and add missing includes to fix no previous prototype error 2023-08-23 15:55:21 +10:00
kexec powerpc: Move DMA64_PROPNAME define to a header 2023-08-18 17:03:15 +10:00
kvm powerpc: Make virt_to_pfn() a static inline 2023-08-16 23:54:49 +10:00
lib powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
math-emu powerpc/math-emu: Inhibit W=1 warnings 2022-09-08 11:11:18 +10:00
mm powerpc/mm: Cleanup memory block size probing 2023-08-18 17:03:15 +10:00
net powerpc/bpf: populate extable entries only during the last pass 2023-05-15 15:40:31 +10:00
perf powerpc/perf: Convert fsl_emb notifier to state machine callbacks 2023-08-18 23:30:53 +10:00
platforms powerpc/powernv: Fix fortify source warnings in opal-prd.c 2023-08-24 22:33:04 +10:00
purgatory powerpc/purgatory: remove PGO flags 2023-06-12 11:31:50 -07:00
sysdev powerpc/85xx: Mark some functions static and add missing includes to fix no previous prototype error 2023-08-23 15:55:21 +10:00
tools powerpc/ftrace: Add support for -fpatchable-function-entry 2023-08-22 00:09:06 +10:00
xmon Revert "powerpc/xmon: Relax frame size for clang" 2023-08-18 17:03:15 +10:00
Kbuild
Kconfig powerpc/ftrace: Add support for -fpatchable-function-entry 2023-08-22 00:09:06 +10:00
Kconfig.debug powerpc: allow PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y 2023-07-03 16:07:55 +10:00
Makefile powerpc/ftrace: Add support for -fpatchable-function-entry 2023-08-22 00:09:06 +10:00
Makefile.postlink kbuild: remove --include-dir MAKEFLAG from top Makefile 2023-02-05 18:51:22 +09:00