Skip to content

Commit 187bea4

Browse files
tiwaiDinh Nguyen
authored andcommitted
ARM: socfpga: Fix crash with CONFIG_FORTIRY_SOURCE
When CONFIG_FORTIFY_SOURCE is set, memcpy() checks the potential buffer overflow and panics. The code in sofcpga bootstrapping contains the memcpy() calls are mistakenly translated as the shorter size, hence it triggers a panic as if it were overflowing. This patch changes the secondary_trampoline and *_end definitions to arrays for avoiding the false-positive crash above. Fixes: 9c4566a ("ARM: socfpga: Enable SMP for socfpga") Suggested-by: Kees Cook <keescook@chromium.org> Buglink: https://bugzilla.suse.com/show_bug.cgi?id=1192473 Link: https://lore.kernel.org/r/20211117193244.31162-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
1 parent fa55b7d commit 187bea4

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎arch/arm/mach-socfpga/core.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern void __iomem *sdr_ctl_base_addr;
3333
u32 socfpga_sdram_self_refresh(u32 sdr_base);
3434
extern unsigned int socfpga_sdram_self_refresh_sz;
3535

36-
extern char secondary_trampoline, secondary_trampoline_end;
36+
extern char secondary_trampoline[], secondary_trampoline_end[];
3737

3838
extern unsigned long socfpga_cpu1start_addr;
3939

‎arch/arm/mach-socfpga/platsmp.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020

2121
static int socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle)
2222
{
23-
int trampoline_size = &secondary_trampoline_end - &secondary_trampoline;
23+
int trampoline_size = secondary_trampoline_end - secondary_trampoline;
2424

2525
if (socfpga_cpu1start_addr) {
2626
/* This will put CPU #1 into reset. */
2727
writel(RSTMGR_MPUMODRST_CPU1,
2828
rst_manager_base_addr + SOCFPGA_RSTMGR_MODMPURST);
2929

30-
memcpy(phys_to_virt(0), &secondary_trampoline, trampoline_size);
30+
memcpy(phys_to_virt(0), secondary_trampoline, trampoline_size);
3131

3232
writel(__pa_symbol(secondary_startup),
3333
sys_manager_base_addr + (socfpga_cpu1start_addr & 0x000000ff));
@@ -45,12 +45,12 @@ static int socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle)
4545

4646
static int socfpga_a10_boot_secondary(unsigned int cpu, struct task_struct *idle)
4747
{
48-
int trampoline_size = &secondary_trampoline_end - &secondary_trampoline;
48+
int trampoline_size = secondary_trampoline_end - secondary_trampoline;
4949

5050
if (socfpga_cpu1start_addr) {
5151
writel(RSTMGR_MPUMODRST_CPU1, rst_manager_base_addr +
5252
SOCFPGA_A10_RSTMGR_MODMPURST);
53-
memcpy(phys_to_virt(0), &secondary_trampoline, trampoline_size);
53+
memcpy(phys_to_virt(0), secondary_trampoline, trampoline_size);
5454

5555
writel(__pa_symbol(secondary_startup),
5656
sys_manager_base_addr + (socfpga_cpu1start_addr & 0x00000fff));

0 commit comments

Comments
 (0)