Re: [PATCH v4 01/13] buildid: Only consider GNU notes for build ID parsing

2021-04-13 Thread Petr Mladek
On Fri 2021-04-09 18:52:48, Stephen Boyd wrote:
> Some kernel elf files have various notes that also happen to have an elf
> note type of '3', which matches NT_GNU_BUILD_ID but the note name isn't
> "GNU". For example, this note trips up the existing logic:
> 
>  Owner  Data size   Description
>  Xen0x0008  Unknown note type: (0x0003) description data: 00 00 
> 00 ff80    
> 
> Let's make sure that it is a GNU note when parsing the build ID so that
> we can use this function to parse a vmlinux's build ID too.
> 
> Reported-by: Petr Mladek 
> Cc: Jiri Olsa 
> Cc: Alexei Starovoitov 
> Cc: Jessica Yu 
> Cc: Evan Green 
> Cc: Hsin-Yi Wang 
> Fixes: bd7525dacd7e ("bpf: Move stack_map_get_build_id into lib")
> Signed-off-by: Stephen Boyd 

Tested-by: Petr Mladek 

Best Regards,
Petr


[PATCH v4 01/13] buildid: Only consider GNU notes for build ID parsing

2021-04-09 Thread Stephen Boyd
Some kernel elf files have various notes that also happen to have an elf
note type of '3', which matches NT_GNU_BUILD_ID but the note name isn't
"GNU". For example, this note trips up the existing logic:

 Owner  Data size   Description
 Xen0x0008  Unknown note type: (0x0003) description data: 00 00 00 
ff80    

Let's make sure that it is a GNU note when parsing the build ID so that
we can use this function to parse a vmlinux's build ID too.

Reported-by: Petr Mladek 
Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Fixes: bd7525dacd7e ("bpf: Move stack_map_get_build_id into lib")
Signed-off-by: Stephen Boyd 
---
 lib/buildid.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/buildid.c b/lib/buildid.c
index 6156997c3895..e014636ec3eb 100644
--- a/lib/buildid.c
+++ b/lib/buildid.c
@@ -31,6 +31,7 @@ static inline int parse_build_id(void *page_addr,
 
if (nhdr->n_type == BUILD_ID &&
nhdr->n_namesz == sizeof("GNU") &&
+   !strcmp((char *)(nhdr + 1), "GNU") &&
nhdr->n_descsz > 0 &&
nhdr->n_descsz <= BUILD_ID_SIZE_MAX) {
memcpy(build_id,
-- 
https://chromeos.dev