Skip to content

Commit 16decce

Browse files
ctmarinaswilldeacon
authored andcommitted
arm64: mte: Fix the stack frame size warning in mte_dump_tag_range()
With 64K page configurations, the tags array stored on the stack of the mte_dump_tag_range() function is 2048 bytes, triggering a compiler warning when CONFIG_FRAME_WARN is enabled. Switch to a kmalloc() allocation via mte_allocate_tag_storage(). Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Fixes: 6dd8b1a ("arm64: mte: Dump the MTE tags in the core file") Reported-by: kernel test robot <lkp@intel.com> Cc: Will Deacon <will@kernel.org> Link: https://lore.kernel.org/r/20220401151356.1674232-1-catalin.marinas@arm.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent a0ab7e5 commit 16decce

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

arch/arm64/kernel/elfcore.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ static unsigned long mte_vma_tag_dump_size(struct vm_area_struct *vma)
2525
static int mte_dump_tag_range(struct coredump_params *cprm,
2626
unsigned long start, unsigned long end)
2727
{
28+
int ret = 1;
2829
unsigned long addr;
30+
void *tags = NULL;
2931

3032
for (addr = start; addr < end; addr += PAGE_SIZE) {
31-
char tags[MTE_PAGE_TAG_STORAGE];
3233
struct page *page = get_dump_page(addr);
3334

3435
/*
@@ -52,13 +53,28 @@ static int mte_dump_tag_range(struct coredump_params *cprm,
5253
continue;
5354
}
5455

56+
if (!tags) {
57+
tags = mte_allocate_tag_storage();
58+
if (!tags) {
59+
put_page(page);
60+
ret = 0;
61+
break;
62+
}
63+
}
64+
5565
mte_save_page_tags(page_address(page), tags);
5666
put_page(page);
57-
if (!dump_emit(cprm, tags, MTE_PAGE_TAG_STORAGE))
58-
return 0;
67+
if (!dump_emit(cprm, tags, MTE_PAGE_TAG_STORAGE)) {
68+
mte_free_tag_storage(tags);
69+
ret = 0;
70+
break;
71+
}
5972
}
6073

61-
return 1;
74+
if (tags)
75+
mte_free_tag_storage(tags);
76+
77+
return ret;
6278
}
6379

6480
Elf_Half elf_core_extra_phdrs(void)

0 commit comments

Comments
 (0)