Nathan Lynch c5a6526711 powerpc/rtas: use memmove for potentially overlapping buffer copy
[ Upstream commit 271208ee5e335cb1ad280d22784940daf7ddf820 ]

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
033ef338b6e0 ("powerpc: Merge rtas.c into arch/powerpc/kernel"); the
old ppc64 version of this code did not have this problem.

Use memmove() instead.

Fixes: 033ef338b6e0 ("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-17 11:13:18 +02:00
..
2019-12-17 20:35:40 +01:00
2019-12-17 20:35:40 +01:00
2018-06-03 21:19:40 +10:00
2019-12-17 20:35:40 +01:00
2022-01-27 09:04:28 +01:00
2018-07-30 22:47:53 +10:00
2022-04-15 14:14:40 +02:00
2019-10-11 18:20:49 +02:00
2018-03-31 09:09:36 +11:00
2018-06-07 10:23:33 -07:00
2023-02-06 07:49:45 +01:00
2020-08-19 08:14:57 +02:00
2018-05-25 12:04:46 +10:00