linux/arch/powerpc/kernel
Nathan Lynch 46f773f39e powerpc/rtas: use memmove for potentially overlapping buffer copy
[ Upstream commit 271208ee5e ]

Using memcpy() isn't safe when buf is identical to rtas_err_buf, which
can happen during boot before slab is up. Full context which may not
be obvious from the diff:

	if (altbuf) {
		buf = altbuf;
	} else {
		buf = rtas_err_buf;
		if (slab_is_available())
			buf = kmalloc(RTAS_ERROR_LOG_MAX, GFP_ATOMIC);
	}
	if (buf)
		memcpy(buf, rtas_err_buf, RTAS_ERROR_LOG_MAX);

This was found by inspection and I'm not aware of it causing problems
in practice. It appears to have been introduced by commit
033ef338b6 ("powerpc: Merge rtas.c into arch/powerpc/kernel"); the
old ppc64 version of this code did not have this problem.

Use memmove() instead.

Fixes: 033ef338b6 ("powerpc: Merge rtas.c into arch/powerpc/kernel")
Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230220-rtas-queue-for-6-4-v1-2-010e4416f13f@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-11 23:03:31 +09:00
..
ptrace powerpc: Don't try to copy PPR for task with NULL pt_regs 2023-04-06 12:10:53 +02:00
syscalls
trace
vdso
.gitignore
85xx_entry_mapping.S
align.c
asm-offsets.c
audit.c
btext.c
cacheinfo.c
cacheinfo.h
compat_audit.c
cpu_setup_6xx.S
cpu_setup_44x.S
cpu_setup_e500.S
cpu_setup_pa6t.S
cpu_setup_power.c
cpu_setup_ppc970.S
cpu_specs_8xx.h
cpu_specs_40x.h
cpu_specs_44x.h
cpu_specs_47x.h
cpu_specs_85xx.h
cpu_specs_book3s_32.h
cpu_specs_book3s_64.h
cpu_specs_e500mc.h
cpu_specs.h
cputable.c
crash_dump.c
dawr.c
dbell.c powerpc/64: Fix perf profiling asynchronous interrupt handlers 2023-02-22 12:59:43 +01:00
dma-iommu.c
dma-mask.c
dma-swiotlb.c
dt_cpu_ftrs.c
early_32.c
eeh_cache.c
eeh_driver.c
eeh_event.c
eeh_pe.c
eeh_sysfs.c
eeh.c
entry_32.S
entry_64.S
epapr_hcalls.S
epapr_paravirt.c
exceptions-64e.S
exceptions-64s.S
fadump.c
firmware.c
fpu.S
head_8xx.S
head_32.h
head_40x.S
head_44x.S
head_64.S
head_85xx.S
head_book3s_32.S
head_booke.h
hw_breakpoint_constraints.c
hw_breakpoint.c
idle_6xx.S
idle_64e.S
idle_85xx.S
idle_book3s.S
idle.c
ima_arch.c
interrupt_64.S
interrupt.c powerpc/64s/interrupt: Fix interrupt exit race with security mitigation switch 2023-02-14 19:11:53 +01:00
io-workarounds.c
io.c
iomap.c
iommu.c powerpc/iommu: fix memory leak with using debugfs_lookup() 2023-03-17 08:50:30 +01:00
irq_64.c powerpc/64: Don't recurse irq replay 2023-03-17 08:50:30 +01:00
irq.c powerpc/64: Fix perf profiling asynchronous interrupt handlers 2023-02-22 12:59:43 +01:00
isa-bridge.c
jump_label.c
kdebugfs.c
kgdb.c
kprobes-ftrace.c
kprobes.c
kvm_emul.S
kvm.c
l2cr_6xx.S
legacy_serial.c
Makefile
mce_power.c
mce.c
misc_32.S
misc_64.S
misc.S
module_32.c
module_64.c
module.c
msi.c
note.S
nvram_64.c
of_platform.c
optprobes_head.S
optprobes.c
paca.c
pci_32.c
pci_64.c
pci_dn.c
pci_of_scan.c
pci-common.c
pci-hotplug.c
pmc.c
ppc_save_regs.S
proc_powerpc.c
process.c
prom_init_check.sh
prom_init.c
prom_parse.c
prom.c powerpc/64: Move paca allocation to early_setup() 2023-03-17 08:50:31 +01:00
reloc_32.S
reloc_64.S
rtas_entry.S
rtas_flash.c
rtas_pci.c
rtas-proc.c
rtas-rtc.c
rtas.c powerpc/rtas: use memmove for potentially overlapping buffer copy 2023-05-11 23:03:31 +09:00
rtasd.c
secure_boot.c
security.c
secvar-ops.c
secvar-sysfs.c
setup_32.c
setup_64.c powerpc/64: Move paca allocation to early_setup() 2023-03-17 08:50:31 +01:00
setup-common.c powerpc/64: Move paca allocation to early_setup() 2023-03-17 08:50:31 +01:00
setup.h
signal_32.c
signal_64.c
signal.c
signal.h
smp-tbsync.c
smp.c
stacktrace.c
static_call.c
suspend.c
swsusp_32.S
swsusp_64.c
swsusp_85xx.S
swsusp_asm64.S
swsusp.c
sys_ppc32.c
syscall.c
syscalls.c
sysfs.c
systbl.c
tau_6xx.c
time.c powerpc/kcsan: Exclude udelay to prevent recursive instrumentation 2023-03-17 08:50:31 +01:00
tm.S
traps.c
ucall.S
udbg_16550.c
udbg.c
uprobes.c
vdso.c
vdso32_wrapper.S
vdso64_wrapper.S
vecemu.c
vector.S
vmlinux.lds.S powerpc/vmlinux.lds: Don't discard .rela* for relocatable builds 2023-02-25 11:25:42 +01:00
watchdog.c