x86/e820: fix the function type for e820__mapped_all
PATCH 1/1 x86/e820: fix the function type for e820__mapped_all
e820__mapped_all is passed as a callback to is_mmconf_reserved, which expects a function of type:
typedef bool (*check_reserved_t)(u64 start, u64 end, unsigned type);
This trips indirect call checking with Clang's Control-Flow Integrity (CFI). Change the last argument from enum e820_type to unsigned to fix the type mismatch.
--- arch/x86/include/asm/e820/api.h | 2 +- arch/x86/kernel/e820.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/e820/api.h +1 -1
@@ -12,7 +12,7 @@ extern unsigned long pci_mem_start;extern bool e820__mapped_raw_any (u64 start,u64 end,enum e820_type type);extern bool e820__mapped_any (u64 start,u64 end,enum e820_type type); -extern bool e820__mapped_all (u64 start,u64 end,enum e820_type type); +extern bool e820__mapped_all (u64 start,u64 end,unsigned type);extern void e820__range_add (u64 start,u64 size,enum e820_type type);extern u64 e820__range_update (u64 start,u64 size,enum e820_type old_type,enum e820_type new_type);
arch/x86/kernel/e820.c +1 -1
@@ -145,7 +145,7 @@ static struct e820_entry *__e820__mapped_all(u64 start, u64 end,/* * This function checks if the entire range <start,end> is mapped with type. */ -bool __init e820__mapped_all (u64 start,u64 end,enum e820_type type) +bool __init e820__mapped_all (u64 start,u64 end,unsigned type) {return __e820__mapped_all (start, end, type); }
base-commit: 585e5b17b92dead8a3aca4e3c9876fbca5f7e0ba
Signature · 1 line
2.29.2.299.gdc1121823c-goog
Quoted 8 lines · Sami Tolvanen
e820__mapped_allis passed as a callback tois_mmconf_reserved, which expects a function of type:typedef bool (*check_reserved_t)(u64 start, u64 end, unsigned type);
This trips indirect call checking with Clang's Control-Flow Integrity (CFI). Change the last argument from enum
e820_typeto unsigned to fix the type mismatch.
Hi,
Kernel style is no raw unsigned -- use unsigned int or unsigned long, please.
checkpatch should or could have found that issue.
Quoted 36 lines
Reported-by Sedat Dilek <[email protected]>Signed-off-by Sami Tolvanen <[email protected]>--- arch/x86/include/asm/e820/api.h | 2 +- arch/x86/kernel/e820.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/x86/include/asm/e820/api.h +1
-1@@ -12,7 +12,7 @@ extern unsigned long pci_mem_start;extern bool e820__mapped_raw_any (u64 start,u64 end,enum e820_type type);extern bool e820__mapped_any (u64 start,u64 end,enum e820_type type); -extern bool e820__mapped_all (u64 start,u64 end,enum e820_type type); +extern bool e820__mapped_all (u64 start,u64 end,unsigned type);extern void e820__range_add (u64 start,u64 size,enum e820_type type);extern u64 e820__range_update (u64 start,u64 size,enum e820_type old_type,enum e820_type new_type);arch/x86/kernel/e820.c +1
-1@@ -145,7 +145,7 @@ static struct e820_entry *__e820__mapped_all(u64 start, u64 end,/* * This function checks if the entire range <start,end> is mapped with type. */ -bool __init e820__mapped_all (u64 start,u64 end,enum e820_type type) +bool __init e820__mapped_all (u64 start,u64 end,unsigned type) {return __e820__mapped_all (start, end, type); }base-commit:
585e5b17b92dead8a3aca4e3c9876fbca5f7e0ba
Signature · 1 line
~Randy
Quoted 11 lines · Randy Dunlap
Quoted 8 lines · Sami Tolvanen
e820__mapped_allis passed as a callback tois_mmconf_reserved, which expects a function of type:typedef bool (*check_reserved_t)(u64 start, u64 end, unsigned type);
This trips indirect call checking with Clang's Control-Flow Integrity (CFI). Change the last argument from enum
e820_typeto unsigned to fix the type mismatch.
Quoted 5 lines
Hi,
Kernel style is no raw unsigned -- use unsigned int or unsigned long, please.
checkpatch should or could have found that issue.
It did, but the existing type definition for the callback in pci/mmconfig-shared.c uses raw unsigned. I can add a patch to change that to unsigned int as well, if you prefer.
Sami
Quoted 14 lines · Sami Tolvanen
Quoted 13 lines · Randy Dunlap
Quoted 8 lines · Sami Tolvanen
e820__mapped_allis passed as a callback tois_mmconf_reserved, which expects a function of type:typedef bool (*check_reserved_t)(u64 start, u64 end, unsigned type);
This trips indirect call checking with Clang's Control-Flow Integrity (CFI). Change the last argument from enum
e820_typeto unsigned to fix the type mismatch.Hi,
Quoted 7 lines
Quoted 3 lines
Kernel style is no raw unsigned -- use unsigned int or unsigned long, please.
checkpatch should or could have found that issue.
It did, but the existing type definition for the callback in
pci/mmconfig-shared.cuses raw unsigned. I can add a patch to change that to unsigned int as well, if you prefer.
Hm. :)
Well, yes, I prefer, but I can't require it.
thanks for the explanation.
Signature · 1 line
~Randy
Borislav Petkov
maintainerQuoted 21 lines · Sami Tolvanen
e820__mapped_allis passed as a callback tois_mmconf_reserved, which expects a function of type:typedef bool (*check_reserved_t)(u64 start, u64 end, unsigned type);
This trips indirect call checking with Clang's Control-Flow Integrity (CFI). Change the last argument from enum
e820_typeto unsigned to fix the type mismatch.Reported-by Sedat Dilek <[email protected]>Signed-off-by Sami Tolvanen <[email protected]>--- arch/x86/include/asm/e820/api.h | 2 +- arch/x86/kernel/e820.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/x86/include/asm/e820/api.h +0
-0
arch/x86/include/asm/e820/api.h extern unsigned long pci_mem_start; · line 15
Quoted 5 lines
arch/x86/include/asm/e820/api.h +1
-1@@ -12,7 +12,7 @@ extern unsigned long pci_mem_start;extern bool e820__mapped_raw_any (u64 start,u64 end,enum e820_type type);extern bool e820__mapped_any (u64 start,u64 end,enum e820_type type); -extern bool e820__mapped_all (u64 start,u64 end,enum e820_type type); +extern bool e820__mapped_all (u64 start,u64 end,unsigned type);
I think the proper fix is to fix the typedef to:
typedef bool (*check_reserved_t)(u64 start, u64 end, enum e820_type type);
because
* is_mmconf_reserved() is passing in E820_TYPE_RESERVED which is enum e820_type
* is_acpi_reserved() is the other check_reserved_t function ptr and the last arg type there is unused so it can just as well be enum e820_type.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 10 lines · Borislav Petkov
I think the proper fix is to fix the typedef to:
typedef bool (*check_reserved_t)(u64 start, u64 end, enum e820_type type);because
*
is_mmconf_reserved()is passing inE820_TYPE_RESERVEDwhich is enume820_type*
is_acpi_reserved()is the othercheck_reserved_tfunction ptr and the last arg type there is unused so it can just as well be enume820_type.
Sure, sounds good. I'll send out v3 to change the type argument to enum e820_type.
Sami