linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: Keep const vars out of writable .sdata
@ 2018-03-01  1:02 Kees Cook
  2018-03-06 13:31 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2018-03-01  1:02 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Christophe Leroy, linux-kernel, Benjamin Herrenschmidt,
	Paul Mackerras, linuxppc-dev, Segher Boessenkool

From: Segher Boessenkool <segher@kernel.crashing.org>

Newer gcc will support "-mno-readonly-in-sdata"[1], which makes sure that
the optimization on PPC32 for variables getting moved into the .sdata
section will not apply to const variables (which must be in .rodata).

This was originally noticed in mm/rodata_test.c when rodata_test_data
was not static:

c0695034 g     O .data	00000004 rodata_test_data

After this patch with an updated compiler, this is correctly in .rodata.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82411

Reported-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Segher Boessenkool <segher@kernel.crashing.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 arch/powerpc/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index ccd2556bdb53..c7628e973084 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -141,7 +141,9 @@ AFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv1)
 endif
 CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
 CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mno-pointers-to-nested-functions)
+
 CFLAGS-$(CONFIG_PPC32)	:= -ffixed-r2 $(MULTIPLEWORD)
+CFLAGS-$(CONFIG_PPC32)	+= $(call cc-option,-mno-readonly-in-sdata)
 
 ifeq ($(CONFIG_PPC_BOOK3S_64),y)
 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,-mtune=power4)
-- 
2.7.4


-- 
Kees Cook
Pixel Security

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: powerpc: Keep const vars out of writable .sdata
  2018-03-01  1:02 [PATCH] powerpc: Keep const vars out of writable .sdata Kees Cook
@ 2018-03-06 13:31 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2018-03-06 13:31 UTC (permalink / raw)
  To: Kees Cook; +Cc: linux-kernel, Paul Mackerras, linuxppc-dev

On Thu, 2018-03-01 at 01:02:49 UTC, Kees Cook wrote:
> From: Segher Boessenkool <segher@kernel.crashing.org>
> 
> Newer gcc will support "-mno-readonly-in-sdata"[1], which makes sure that
> the optimization on PPC32 for variables getting moved into the .sdata
> section will not apply to const variables (which must be in .rodata).
> 
> This was originally noticed in mm/rodata_test.c when rodata_test_data
> was not static:
> 
> c0695034 g     O .data	00000004 rodata_test_data
> 
> After this patch with an updated compiler, this is correctly in .rodata.
> 
> [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82411
> 
> Reported-by: Christophe Leroy <christophe.leroy@c-s.fr>
> Signed-off-by: Segher Boessenkool <segher@kernel.crashing.org>
> Signed-off-by: Kees Cook <keescook@chromium.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/51d42f0f5fd6c74144d19bf6a66352

cheers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-06 13:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-01  1:02 [PATCH] powerpc: Keep const vars out of writable .sdata Kees Cook
2018-03-06 13:31 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).