Skip to contentSkip to conversation

ubsan: don't mark __ubsan_handle_builtin_unreachable as noreturn

PATCH In review Arnd Bergmann 4 participants 10 messages Feb 2, 2018 – Nov 7, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ubsan: don't mark __ubsan_handle_builtin_unreachable as noreturn

gcc-8 complains about the prototype for this function:

lib/ubsan.c:432:1: error: ignoring attribute 'noreturn' in declaration of a built-in function '__ubsan_handle_builtin_unreachable' because it conflicts with attribute 'const' [-Werror=attributes]

This removes the noreturn attribute.

---
 lib/ubsan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/ubsan.c +1 -1
index 59fee96c29a0..aa817d79c47c 100644
@@ -427,7 +427,7 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
 EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
 
 
-void __noreturn
+void
 __ubsan_handle_builtin_unreachable(struct unreachable_data *data)
 {
 	unsigned long flags;
Signature · 1 line
2.9.0
#1 lore raw
Quoted 4 lines · Arnd Bergmann

gcc-8 complains about the prototype for this function:

lib/ubsan.c:432:1: error: ignoring attribute 'noreturn' in declaration of a built-in function '__ubsan_handle_builtin_unreachable' because it conflicts with attribute 'const' [-Werror=attributes]

That's actually a bug in GCC. In GCC __ubsan_handle_builtin_unreachable declared with 'noreturn' and 'const' attributes:

DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE,

                      "__ubsan_handle_builtin_unreachable",                                                                                                                                                         
                      BT_FN_VOID_PTR,                                                                                                                                                                               
                      ATTR_COLD_CONST_NORETURN_NOTHROW_LEAF_LIST)

But const attribute doesn't make any sense for function that returns void or doesn't return at all. Given that gcc-8 has not released yet, it would be better to fix this bug there.

#2 lore raw
Quoted 11 lines · Andrey Ryabinin
Quoted 4 lines · Arnd Bergmann

gcc-8 complains about the prototype for this function:

lib/ubsan.c:432:1: error: ignoring attribute 'noreturn' in declaration of a built-in function '__ubsan_handle_builtin_unreachable' because it conflicts with attribute 'const' [-Werror=attributes]

That's actually a bug in GCC. In GCC __ubsan_handle_builtin_unreachable declared with 'noreturn' and 'const' attributes:

Quoted 8 lines

DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE,

                      "__ubsan_handle_builtin_unreachable",
                      BT_FN_VOID_PTR,
                      ATTR_COLD_CONST_NORETURN_NOTHROW_LEAF_LIST)

But const attribute doesn't make any sense for function that returns void or doesn't return at all. Given that gcc-8 has not released yet, it would be better to fix this bug there.

Ok. Should I open a gcc bug, or will you take care of it?

Arnd

#3 lore raw
Quoted 19 lines · Arnd Bergmann
Quoted 17 lines · Andrey Ryabinin
Quoted 4 lines · Arnd Bergmann

gcc-8 complains about the prototype for this function:

lib/ubsan.c:432:1: error: ignoring attribute 'noreturn' in declaration of a built-in function '__ubsan_handle_builtin_unreachable' because it conflicts with attribute 'const' [-Werror=attributes]

That's actually a bug in GCC. In GCC __ubsan_handle_builtin_unreachable declared with 'noreturn' and 'const' attributes:

DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE,

                      "__ubsan_handle_builtin_unreachable",
                      BT_FN_VOID_PTR,
                      ATTR_COLD_CONST_NORETURN_NOTHROW_LEAF_LIST)
Quoted 5 lines
Quoted 2 lines

But const attribute doesn't make any sense for function that returns void or doesn't return at all. Given that gcc-8 has not released yet, it would be better to fix this bug there.

Ok. Should I open a gcc bug, or will you take care of it?

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84210

Quoted 2 lines

Arnd

#4 lore raw
Quoted 21 lines · Andrey Ryabinin
Quoted 19 lines · Arnd Bergmann
Quoted 17 lines · Andrey Ryabinin
Quoted 4 lines · Arnd Bergmann

gcc-8 complains about the prototype for this function:

lib/ubsan.c:432:1: error: ignoring attribute 'noreturn' in declaration of a built-in function '__ubsan_handle_builtin_unreachable' because it conflicts with attribute 'const' [-Werror=attributes]

That's actually a bug in GCC. In GCC __ubsan_handle_builtin_unreachable declared with 'noreturn' and 'const' attributes:

DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE,

                      "__ubsan_handle_builtin_unreachable",
                      BT_FN_VOID_PTR,
                      ATTR_COLD_CONST_NORETURN_NOTHROW_LEAF_LIST)
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

But const attribute doesn't make any sense for function that returns void or doesn't return at all. Given that gcc-8 has not released yet, it would be better to fix this bug there.

Ok. Should I open a gcc bug, or will you take care of it?

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84210

8.2.0 still shows this, and there's been no movement on that bug. How about we pick up this patch until it's been resolved?

-Olof

#5 lore raw
Quoted 25 lines · Olof Johansson
Quoted 24 lines · Andrey Ryabinin
Quoted 22 lines · Arnd Bergmann
Quoted 19 lines · Andrey Ryabinin
Quoted 4 lines · Arnd Bergmann

gcc-8 complains about the prototype for this function:

lib/ubsan.c:432:1: error: ignoring attribute 'noreturn' in declaration of a built-in function '__ubsan_handle_builtin_unreachable' because it conflicts with attribute 'const' [-Werror=attributes]

That's actually a bug in GCC. In GCC __ubsan_handle_builtin_unreachable declared with 'noreturn' and 'const' attributes:

DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE,

                      "__ubsan_handle_builtin_unreachable",
                      BT_FN_VOID_PTR,
                      ATTR_COLD_CONST_NORETURN_NOTHROW_LEAF_LIST)

But const attribute doesn't make any sense for function that returns void or doesn't return at all. Given that gcc-8 has not released yet, it would be better to fix this bug there.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Ok. Should I open a gcc bug, or will you take care of it?

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84210

8.2.0 still shows this, and there's been no movement on that bug. How about we pick up this patch until it's been resolved?

Sure, I'll add info about GCC bug in changelog and resend the patch.

Quoted 3 lines

-Olof

#6 lore raw

PATCH v2 1/1 ubsan: don't mark __ubsan_handle_builtin_unreachable as noreturn

In reply to Olof Johansson

From: Arnd Bergmann <[email protected]>

gcc-8 complains about the prototype for this function:

lib/ubsan.c:432:1: error: ignoring attribute 'noreturn' in declaration of a built-in function '__ubsan_handle_builtin_unreachable' because it conflicts with attribute 'const' [-Werror=attributes]

This is actually a GCC's bug. In GCC internals __ubsan_handle_builtin_unreachable() declared with both 'noreturn' and 'const' attributes instead of only 'noreturn':
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84210

Workaround this by removing the noreturn attribute.

[aryabinin: Add information about GCC bug in changelog]
---
 lib/ubsan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
lib/ubsan.c +1 -2
index 59fee96c29a0..e4162f59a81c 100644
@@ -427,8 +427,7 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
 EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
 
 
-void __noreturn
-__ubsan_handle_builtin_unreachable(struct unreachable_data *data)
+void __ubsan_handle_builtin_unreachable(struct unreachable_data *data)
 {
 	unsigned long flags;
 
Signature · 1 line
2.18.1
Acked-by on v2 1/1
#7 lore raw
Quoted 10 lines · Andrey Ryabinin

From: Arnd Bergmann <[email protected]>

gcc-8 complains about the prototype for this function:

lib/ubsan.c:432:1: error: ignoring attribute 'noreturn' in declaration of a built-in function '__ubsan_handle_builtin_unreachable' because it conflicts with attribute 'const' [-Werror=attributes]

This is actually a GCC's bug. In GCC internals __ubsan_handle_builtin_unreachable() declared with both 'noreturn' and 'const' attributes instead of only 'noreturn':

Quoted 7 lines
   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84210

Workaround this by removing the noreturn attribute.

[aryabinin: Add information about GCC bug in changelog]

While it's a GCC bug, it's there in official releases now and it makes warnings noisy so we'd rather silence it.

-Olof

maintainer
#8 lore raw
In reply to Andrey Ryabinin
Quoted 18 lines · On Wed, 7 Nov 2018 17:45:16 +0300 Andrey Ryabinin <[email protected]>…

From: Arnd Bergmann <[email protected]>

gcc-8 complains about the prototype for this function:

lib/ubsan.c:432:1: error: ignoring attribute 'noreturn' in declaration of a built-in function '__ubsan_handle_builtin_unreachable' because it conflicts with attribute 'const' [-Werror=attributes]

This is actually a GCC's bug. In GCC internals __ubsan_handle_builtin_unreachable() declared with both 'noreturn' and 'const' attributes instead of only 'noreturn':

   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84210

Workaround this by removing the noreturn attribute.

...

lib/ubsan.c void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data, · line 432

Quoted 8 lines
lib/ubsan.c +1 -2
@@ -427,8 +427,7 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
 EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
 
 
-void __noreturn
-__ubsan_handle_builtin_unreachable(struct unreachable_data *data)
+void __ubsan_handle_builtin_unreachable(struct unreachable_data *data)
 {
 	unsigned long flags;

This code has been here since 2016 and presumably people will want to build older kernels with newer gcc's. So I'll add cc:stable, OK?

#9 lore raw
Quoted 11 lines · Andrew Morton
Quoted 8 lines · On Wed, 7 Nov 2018 17:45:16 +0300 Andrey Ryabinin <[email protected]>…

From: Arnd Bergmann <[email protected]>

lib/ubsan.c +0 -0
@@ -427,8 +427,7 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
 EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
 
 
Quoted 9 lines

lib/ubsan.c void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data, · line 432

Quoted 5 lines
lib/ubsan.c +1 -2
-void __noreturn
-__ubsan_handle_builtin_unreachable(struct unreachable_data *data)
+void __ubsan_handle_builtin_unreachable(struct unreachable_data *data)
 {
      unsigned long flags;

This code has been here since 2016 and presumably people will want to build older kernels with newer gcc's. So I'll add cc:stable, OK?

Yes, sounds good. Thanks,

arnd