xen/ubsan: Fix UB in type_descriptor declaration
PATCH 1/1 xen/ubsan: Fix UB in type_descriptor declaration
struct type_descriptor is arranged with a NUL terminated string following the kind/info fields.
The only reason this doesn't trip UBSAN detection itself (on more modern compilers at least) is because struct type_descriptor is only referenced in suppressed regions.
Switch the declaration to be a real flexible member. No functional change.
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Oleksii Kurochko <[email protected]>
For 4.19, and for backport to all reasonable versions. This bug deserves some kind of irony award.
--- xen/common/ubsan/ubsan.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/ubsan/ubsan.h +1 -1
@@ -10,7 +10,7 @@ enum {struct type_descriptor {u16 type_kind;u16 type_info; -char type_name[1 ]; +char type_name[]; };struct source_location {
base-commit: 8b4243a9b560c89bb259db5a27832c253d4bebc7
Signature · 1 line
2.39.2
Quoted 11 lines · Andrew Cooper
struct
type_descriptoris arranged with a NUL terminated string following the kind/info fields.The only reason this doesn't trip UBSAN detection itself (on more modern compilers at least) is because struct
type_descriptoris only referenced in suppressed regions.Switch the declaration to be a real flexible member. No functional change.
Fixes 00fcf4dd8eb4 ("xen/ubsan: Import ubsan implementation from Linux 4.13")Signed-off-by Andrew Cooper <[email protected]>
Quoted 1 line · Andrew Cooper
struct
type_descriptoris arranged with a NUL terminated string
Should it be NULL instead of NUL?
Quoted 9 lines
following the
kind/info fields.The only reason this doesn't trip UBSAN detection itself (on more modern
compilers at least) is because structtype_descriptoris only referenced in
suppressed regions.
Quoted 6 lines
Switch the declaration to be a real flexible member. No functional change.
Fixes 00fcf4dd8eb4 ("xen/ubsan: Import ubsan implementation fromLinux 4.13")
Signed-off-by Andrew Cooper <[email protected]>
~ Oleksii
Quoted 29 lines
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Oleksii Kurochko <[email protected]>For 4.19, and for backport to all reasonable versions. This bug deserves some
kind of irony award.
---
xen/common/ubsan/ubsan.h | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)xen/common/ubsan/ubsan.h +1
-1@@ -10,7 +10,7 @@ enum { struct type_descriptor { u16 type_kind; u16 type_info; -char type_name[1 ]; +char type_name[]; };
structsource_location{base-commit:
8b4243a9b560c89bb259db5a27832c253d4bebc7
Quoted 3 lines · Oleksii K.
Quoted 1 line · Andrew Cooper
struct
type_descriptoris arranged with a NUL terminated stringShould it be NULL instead of NUL?
NULL and NUL can be used interchangeably; they're different spellings for the same thing.
In the ASCII spec, the character with value 0 is spelt NUL.
Quoted 10 lines
Quoted 10 lines
following the
kind/info fields.The only reason this doesn't trip UBSAN detection itself (on more modern
compilers at least) is because structtype_descriptoris only referenced in
suppressed regions.
Quoted 7 lines
Quoted 6 lines
Switch the declaration to be a real flexible member. No functional change.
Fixes 00fcf4dd8eb4 ("xen/ubsan: Import ubsan implementation fromLinux 4.13")
Signed-off-by Andrew Cooper <[email protected]>Release-Acked-by Oleksii Kurochko <[email protected]>
Thanks.
~Andrew