All of lore.kernel.org
 help / color / mirror / Atom feed
From: gregory.clement@bootlin.com (Gregory CLEMENT)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: mvebu: declare asm symbols as character arrays in pmsu.c
Date: Wed, 27 Jun 2018 08:20:37 +0200	[thread overview]
Message-ID: <87wouk92dm.fsf@bootlin.com> (raw)
In-Reply-To: <20180620043109.1190-1-ethan@ethantuttle.com> (Ethan Tuttle's message of "Tue, 19 Jun 2018 21:31:08 -0700")

Hi Ethan,
 
 On mar., juin 19 2018, Ethan Tuttle <ethan@ethantuttle.com> wrote:

> With CONFIG_FORTIFY_SOURCE, memcpy uses the declared size of operands to
> detect buffer overflows.  If src or dest is declared as a char, attempts to
> copy more than byte will result in a fortify_panic().
>
> Address this problem in mvebu_setup_boot_addr_wa() by declaring
> mvebu_boot_wa_start and mvebu_boot_wa_end as character arrays.  Also remove
> a couple addressof operators to avoid "arithmetic on pointer to an
> incomplete type" compiler error.
>
> See commit 54a7d50b9205 ("x86: mark kprobe templates as character arrays,
> not single characters") for a similar fix.
>
> Fixes "detected buffer overflow in memcpy" error during init on some mvebu
> systems (armada-370-xp, armada-375):
>
> (fortify_panic) from (mvebu_setup_boot_addr_wa+0xb0/0xb4)
> (mvebu_setup_boot_addr_wa) from (mvebu_v7_cpu_pm_init+0x154/0x204)
> (mvebu_v7_cpu_pm_init) from (do_one_initcall+0x7c/0x1a8)
> (do_one_initcall) from (kernel_init_freeable+0x1bc/0x254)
> (kernel_init_freeable) from (kernel_init+0x8/0x114)
> (kernel_init) from (ret_from_fork+0x14/0x2c)
>
> Signed-off-by: Ethan Tuttle <ethan@ethantuttle.com>
> Tested-by: Ethan Tuttle <ethan@ethantuttle.com>

Out of curiosity on which platform did you test it?

Applied on mvebu/arm

Thanks,

Gregory



> ---
>  arch/arm/mach-mvebu/pmsu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c
> index 27a78c80e5b1..73d5d72dfc3e 100644
> --- a/arch/arm/mach-mvebu/pmsu.c
> +++ b/arch/arm/mach-mvebu/pmsu.c
> @@ -116,8 +116,8 @@ void mvebu_pmsu_set_cpu_boot_addr(int hw_cpu, void *boot_addr)
>  		PMSU_BOOT_ADDR_REDIRECT_OFFSET(hw_cpu));
>  }
>  
> -extern unsigned char mvebu_boot_wa_start;
> -extern unsigned char mvebu_boot_wa_end;
> +extern unsigned char mvebu_boot_wa_start[];
> +extern unsigned char mvebu_boot_wa_end[];
>  
>  /*
>   * This function sets up the boot address workaround needed for SMP
> @@ -130,7 +130,7 @@ int mvebu_setup_boot_addr_wa(unsigned int crypto_eng_target,
>  			     phys_addr_t resume_addr_reg)
>  {
>  	void __iomem *sram_virt_base;
> -	u32 code_len = &mvebu_boot_wa_end - &mvebu_boot_wa_start;
> +	u32 code_len = mvebu_boot_wa_end - mvebu_boot_wa_start;
>  
>  	mvebu_mbus_del_window(BOOTROM_BASE, BOOTROM_SIZE);
>  	mvebu_mbus_add_window_by_id(crypto_eng_target, crypto_eng_attribute,
> -- 
> 2.17.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
Gregory Clement, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com

WARNING: multiple messages have this Message-ID (diff)
From: Gregory CLEMENT <gregory.clement@bootlin.com>
To: Ethan Tuttle <ethan@ethantuttle.com>
Cc: Andrew Lunn <andrew@lunn.ch>, Jason Cooper <jason@lakedaemon.net>,
	Russell King <linux@armlinux.org.uk>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Subject: Re: [PATCH] ARM: mvebu: declare asm symbols as character arrays in pmsu.c
Date: Wed, 27 Jun 2018 08:20:37 +0200	[thread overview]
Message-ID: <87wouk92dm.fsf@bootlin.com> (raw)
In-Reply-To: <20180620043109.1190-1-ethan@ethantuttle.com> (Ethan Tuttle's message of "Tue, 19 Jun 2018 21:31:08 -0700")

Hi Ethan,
 
 On mar., juin 19 2018, Ethan Tuttle <ethan@ethantuttle.com> wrote:

> With CONFIG_FORTIFY_SOURCE, memcpy uses the declared size of operands to
> detect buffer overflows.  If src or dest is declared as a char, attempts to
> copy more than byte will result in a fortify_panic().
>
> Address this problem in mvebu_setup_boot_addr_wa() by declaring
> mvebu_boot_wa_start and mvebu_boot_wa_end as character arrays.  Also remove
> a couple addressof operators to avoid "arithmetic on pointer to an
> incomplete type" compiler error.
>
> See commit 54a7d50b9205 ("x86: mark kprobe templates as character arrays,
> not single characters") for a similar fix.
>
> Fixes "detected buffer overflow in memcpy" error during init on some mvebu
> systems (armada-370-xp, armada-375):
>
> (fortify_panic) from (mvebu_setup_boot_addr_wa+0xb0/0xb4)
> (mvebu_setup_boot_addr_wa) from (mvebu_v7_cpu_pm_init+0x154/0x204)
> (mvebu_v7_cpu_pm_init) from (do_one_initcall+0x7c/0x1a8)
> (do_one_initcall) from (kernel_init_freeable+0x1bc/0x254)
> (kernel_init_freeable) from (kernel_init+0x8/0x114)
> (kernel_init) from (ret_from_fork+0x14/0x2c)
>
> Signed-off-by: Ethan Tuttle <ethan@ethantuttle.com>
> Tested-by: Ethan Tuttle <ethan@ethantuttle.com>

Out of curiosity on which platform did you test it?

Applied on mvebu/arm

Thanks,

Gregory



> ---
>  arch/arm/mach-mvebu/pmsu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c
> index 27a78c80e5b1..73d5d72dfc3e 100644
> --- a/arch/arm/mach-mvebu/pmsu.c
> +++ b/arch/arm/mach-mvebu/pmsu.c
> @@ -116,8 +116,8 @@ void mvebu_pmsu_set_cpu_boot_addr(int hw_cpu, void *boot_addr)
>  		PMSU_BOOT_ADDR_REDIRECT_OFFSET(hw_cpu));
>  }
>  
> -extern unsigned char mvebu_boot_wa_start;
> -extern unsigned char mvebu_boot_wa_end;
> +extern unsigned char mvebu_boot_wa_start[];
> +extern unsigned char mvebu_boot_wa_end[];
>  
>  /*
>   * This function sets up the boot address workaround needed for SMP
> @@ -130,7 +130,7 @@ int mvebu_setup_boot_addr_wa(unsigned int crypto_eng_target,
>  			     phys_addr_t resume_addr_reg)
>  {
>  	void __iomem *sram_virt_base;
> -	u32 code_len = &mvebu_boot_wa_end - &mvebu_boot_wa_start;
> +	u32 code_len = mvebu_boot_wa_end - mvebu_boot_wa_start;
>  
>  	mvebu_mbus_del_window(BOOTROM_BASE, BOOTROM_SIZE);
>  	mvebu_mbus_add_window_by_id(crypto_eng_target, crypto_eng_attribute,
> -- 
> 2.17.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
Gregory Clement, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com

  reply	other threads:[~2018-06-27  6:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-20  4:31 [PATCH] ARM: mvebu: declare asm symbols as character arrays in pmsu.c Ethan Tuttle
2018-06-20  4:31 ` Ethan Tuttle
2018-06-27  6:20 ` Gregory CLEMENT [this message]
2018-06-27  6:20   ` Gregory CLEMENT
2018-06-27 14:39   ` Ethan Tuttle
2018-06-27 14:39     ` Ethan Tuttle
2018-06-28 13:07     ` Gregory CLEMENT
2018-06-28 13:07       ` Gregory CLEMENT

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wouk92dm.fsf@bootlin.com \
    --to=gregory.clement@bootlin.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.