All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH sparc] sparc: Fix -Wstringop-overflow warning
@ 2017-05-16 19:34 Orlando Arias
  2017-05-17 19:09 ` [PATCH sparc] sparc: Fix -Wstringop-overflow warning,[PATCH sparc] sparc: Fix -Wstringop-overflo David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Orlando Arias @ 2017-05-16 19:34 UTC (permalink / raw)
  To: sparclinux


[-- Attachment #1.1: Type: text/plain, Size: 2657 bytes --]

Greetings,

GCC 7 introduced the -Wstringop-overflow flag to detect buffer overflows
in calls to string handling functions [1][2]. Due to the way
``empty_zero_page'' is declared in arch/sparc/include/setup.h, this
causes a warning to trigger at compile time in the function mem_init(),
which is subsequently converted to an error. The ensuing patch fixes
this issue and aligns the declaration of empty_zero_page to that of
other architectures. Thank you.

Cheers,
Orlando.


[1] https://gcc.gnu.org/ml/gcc-patches/2016-10/msg02308.html
[2] https://gcc.gnu.org/gcc-7/changes.html


Signed-off-by: Orlando Arias <oarias@knights.ucf.edu>

--------------------------------------------------------------------------------
diff -rupN linux-4.11.1-pristine/arch/sparc/include/asm/pgtable_32.h linux-4.11.1-modified/arch/sparc/include/asm/pgtable_32.h
--- linux-4.11.1-pristine/arch/sparc/include/asm/pgtable_32.h	2017-05-14 08:06:16.000000000 -0400
+++ linux-4.11.1-modified/arch/sparc/include/asm/pgtable_32.h	2017-05-16 14:08:21.220784497 -0400
@@ -91,9 +91,9 @@ extern unsigned long pfn_base;
  * ZERO_PAGE is a global shared page that is always zero: used
  * for zero-mapped memory areas etc..
  */
-extern unsigned long empty_zero_page;
+extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
 
-#define ZERO_PAGE(vaddr) (virt_to_page(&empty_zero_page))
+#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
 
 /*
  * In general all page table modifications should use the V8 atomic
diff -rupN linux-4.11.1-pristine/arch/sparc/include/asm/setup.h linux-4.11.1-modified/arch/sparc/include/asm/setup.h
--- linux-4.11.1-pristine/arch/sparc/include/asm/setup.h	2017-05-14 08:06:16.000000000 -0400
+++ linux-4.11.1-modified/arch/sparc/include/asm/setup.h	2017-05-16 14:05:31.887441581 -0400
@@ -16,7 +16,7 @@ extern char reboot_command[];
  */
 extern unsigned char boot_cpu_id;
 
-extern unsigned long empty_zero_page;
+extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
 
 extern int serial_console;
 static inline int con_is_present(void)
diff -rupN linux-4.11.1-pristine/arch/sparc/mm/init_32.c linux-4.11.1-modified/arch/sparc/mm/init_32.c
--- linux-4.11.1-pristine/arch/sparc/mm/init_32.c	2017-05-14 08:06:16.000000000 -0400
+++ linux-4.11.1-modified/arch/sparc/mm/init_32.c	2017-05-16 14:06:02.497443313 -0400
@@ -290,7 +290,7 @@ void __init mem_init(void)
 
 
 	/* Saves us work later. */
-	memset((void *)&empty_zero_page, 0, PAGE_SIZE);
+	memset((void *)empty_zero_page, 0, PAGE_SIZE);
 
 	i = last_valid_pfn >> ((20 - PAGE_SHIFT) + 5);
 	i += 1;


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH sparc] sparc: Fix -Wstringop-overflow warning,[PATCH sparc] sparc: Fix -Wstringop-overflo
  2017-05-16 19:34 [PATCH sparc] sparc: Fix -Wstringop-overflow warning Orlando Arias
@ 2017-05-17 19:09 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-05-17 19:09 UTC (permalink / raw)
  To: sparclinux

From: Orlando Arias <oarias@knights.ucf.edu>
Date: Tue, 16 May 2017 15:34:00 -0400

> Greetings,
> 
> GCC 7 introduced the -Wstringop-overflow flag to detect buffer overflows
> in calls to string handling functions [1][2]. Due to the way
> ``empty_zero_page'' is declared in arch/sparc/include/setup.h, this
> causes a warning to trigger at compile time in the function mem_init(),
> which is subsequently converted to an error. The ensuing patch fixes
> this issue and aligns the declaration of empty_zero_page to that of
> other architectures. Thank you.
> 
> Cheers,
> Orlando.
> 
> 
> [1] https://gcc.gnu.org/ml/gcc-patches/2016-10/msg02308.html
> [2] https://gcc.gnu.org/gcc-7/changes.html
> 
> 
> Signed-off-by: Orlando Arias <oarias@knights.ucf.edu>

Applied.

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

end of thread, other threads:[~2017-05-17 19:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-16 19:34 [PATCH sparc] sparc: Fix -Wstringop-overflow warning Orlando Arias
2017-05-17 19:09 ` [PATCH sparc] sparc: Fix -Wstringop-overflow warning,[PATCH sparc] sparc: Fix -Wstringop-overflo David Miller

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.