diff mbox

[PR,sanitizer/78887] Don't emit ODR indicators if -fsanitize=kernel-address is present.

Message ID 58788D87.7040104@samsung.com
State Superseded
Headers show

Commit Message

Maxim Ostapenko Jan. 13, 2017, 8:19 a.m. UTC
Hi,

as mentioned in PR, Linux kernel 4.9 fails to build with ASan due to 
wrong handling of emitted ODR indicator symbols. Although this might be 
a kernel bug (relying on specific pattern in symbol name sounds 
questionable), kernel doesn't need ODR indicators at all thus we can 
just disable them if -fsanitize=kernel-address is present.
Tested on x86_64-unknown-linux-gnu, OK for trunk?

-Maxim

Comments

Jakub Jelinek Jan. 13, 2017, 8:24 a.m. UTC | #1
On Fri, Jan 13, 2017 at 11:19:19AM +0300, Maxim Ostapenko wrote:
> as mentioned in PR, Linux kernel 4.9 fails to build with ASan due to wrong

> handling of emitted ODR indicator symbols. Although this might be a kernel

> bug (relying on specific pattern in symbol name sounds questionable), kernel

> doesn't need ODR indicators at all thus we can just disable them if

> -fsanitize=kernel-address is present.

> Tested on x86_64-unknown-linux-gnu, OK for trunk?


> gcc/ChangeLog:

> 

> 2017-01-13  Maxim Ostapenko  <m.ostapenko@samsung.com>

> 

> 	PR sanitizer/78887

> 	* asan.c (asan_needs_odr_indicator_p): Don't emit ODR indicators

> 	if -fsanitize=kernel-address is present.

> 

> diff --git a/gcc/asan.c b/gcc/asan.c

> index bc7ebc8..157d468 100644

> --- a/gcc/asan.c

> +++ b/gcc/asan.c

> @@ -2360,7 +2360,8 @@ create_odr_indicator (tree decl, tree type)

>  static bool

>  asan_needs_odr_indicator_p (tree decl)

>  {

> -  return !DECL_ARTIFICIAL (decl) && !DECL_WEAK (decl) && TREE_PUBLIC (decl);

> +  return !(flag_sanitize & SANITIZE_KERNEL_ADDRESS) && !DECL_ARTIFICIAL (decl)

> +	 && !DECL_WEAK (decl) && TREE_PUBLIC (decl);


As the condition is longer than a line, please use
  return (!(flag_sanitize & SANITIZE_KERNEL_ADDRESS)
	  && !DECL_ARTIFICIAL (decl)
	  && !DECL_WEAK (decl)
	  && TREE_PUBLIC (decl));
instead (i.e. one sub-condition per line, and ()s around the whole
condition.  Perhaps a short comment why we don't emit those for
-fsanitize=kernel-address would be useful too.

Ok for trunk with those changes.

	Jakub
diff mbox

Patch

gcc/ChangeLog:

2017-01-13  Maxim Ostapenko  <m.ostapenko@samsung.com>

	PR sanitizer/78887
	* asan.c (asan_needs_odr_indicator_p): Don't emit ODR indicators
	if -fsanitize=kernel-address is present.

diff --git a/gcc/asan.c b/gcc/asan.c
index bc7ebc8..157d468 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -2360,7 +2360,8 @@  create_odr_indicator (tree decl, tree type)
 static bool
 asan_needs_odr_indicator_p (tree decl)
 {
-  return !DECL_ARTIFICIAL (decl) && !DECL_WEAK (decl) && TREE_PUBLIC (decl);
+  return !(flag_sanitize & SANITIZE_KERNEL_ADDRESS) && !DECL_ARTIFICIAL (decl)
+	 && !DECL_WEAK (decl) && TREE_PUBLIC (decl);
 }
 
 /* Append description of a single global DECL into vector V.