]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.131/arm-mvebu-declare-asm-symbols-as-character-arrays-in-pmsu.c.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.131 / arm-mvebu-declare-asm-symbols-as-character-arrays-in-pmsu.c.patch
1 From foo@baz Sat Sep 29 04:29:21 PDT 2018
2 From: Ethan Tuttle <ethan@ethantuttle.com>
3 Date: Tue, 19 Jun 2018 21:31:08 -0700
4 Subject: ARM: mvebu: declare asm symbols as character arrays in pmsu.c
5
6 From: Ethan Tuttle <ethan@ethantuttle.com>
7
8 [ Upstream commit d0d378ff451a66e486488eec842e507d28145813 ]
9
10 With CONFIG_FORTIFY_SOURCE, memcpy uses the declared size of operands to
11 detect buffer overflows. If src or dest is declared as a char, attempts to
12 copy more than byte will result in a fortify_panic().
13
14 Address this problem in mvebu_setup_boot_addr_wa() by declaring
15 mvebu_boot_wa_start and mvebu_boot_wa_end as character arrays. Also remove
16 a couple addressof operators to avoid "arithmetic on pointer to an
17 incomplete type" compiler error.
18
19 See commit 54a7d50b9205 ("x86: mark kprobe templates as character arrays,
20 not single characters") for a similar fix.
21
22 Fixes "detected buffer overflow in memcpy" error during init on some mvebu
23 systems (armada-370-xp, armada-375):
24
25 (fortify_panic) from (mvebu_setup_boot_addr_wa+0xb0/0xb4)
26 (mvebu_setup_boot_addr_wa) from (mvebu_v7_cpu_pm_init+0x154/0x204)
27 (mvebu_v7_cpu_pm_init) from (do_one_initcall+0x7c/0x1a8)
28 (do_one_initcall) from (kernel_init_freeable+0x1bc/0x254)
29 (kernel_init_freeable) from (kernel_init+0x8/0x114)
30 (kernel_init) from (ret_from_fork+0x14/0x2c)
31
32 Signed-off-by: Ethan Tuttle <ethan@ethantuttle.com>
33 Tested-by: Ethan Tuttle <ethan@ethantuttle.com>
34 Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
35 Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
36 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
37 ---
38 arch/arm/mach-mvebu/pmsu.c | 6 +++---
39 1 file changed, 3 insertions(+), 3 deletions(-)
40
41 --- a/arch/arm/mach-mvebu/pmsu.c
42 +++ b/arch/arm/mach-mvebu/pmsu.c
43 @@ -116,8 +116,8 @@ void mvebu_pmsu_set_cpu_boot_addr(int hw
44 PMSU_BOOT_ADDR_REDIRECT_OFFSET(hw_cpu));
45 }
46
47 -extern unsigned char mvebu_boot_wa_start;
48 -extern unsigned char mvebu_boot_wa_end;
49 +extern unsigned char mvebu_boot_wa_start[];
50 +extern unsigned char mvebu_boot_wa_end[];
51
52 /*
53 * This function sets up the boot address workaround needed for SMP
54 @@ -130,7 +130,7 @@ int mvebu_setup_boot_addr_wa(unsigned in
55 phys_addr_t resume_addr_reg)
56 {
57 void __iomem *sram_virt_base;
58 - u32 code_len = &mvebu_boot_wa_end - &mvebu_boot_wa_start;
59 + u32 code_len = mvebu_boot_wa_end - mvebu_boot_wa_start;
60
61 mvebu_mbus_del_window(BOOTROM_BASE, BOOTROM_SIZE);
62 mvebu_mbus_add_window_by_id(crypto_eng_target, crypto_eng_attribute,