Skip to content

Commit

Permalink
ARM: 8748/1: mm: Define vdso_start, vdso_end as array
Browse files Browse the repository at this point in the history
Define vdso_start, vdso_end as array to avoid compile-time analysis error
for the case of built with CONFIG_FORTIFY_SOURCE.

and, since vdso_start, vdso_end are used in vdso.c only,
move extern-declaration from vdso.h to vdso.c.

If kernel is built with CONFIG_FORTIFY_SOURCE,
compile-time error happens at this code.
- if (memcmp(&vdso_start, "177ELF", 4))

The size of "&vdso_start" is recognized as 1 byte, but n is 4,
So that compile-time error is reported.

Acked-by: Kees Cook <[email protected]>
Signed-off-by: Jinbum Park <[email protected]>
Signed-off-by: Russell King <[email protected]>
  • Loading branch information
jinb-park authored and Russell King committed Mar 24, 2018
1 parent ad43fc9 commit 73b9160
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 0 additions & 2 deletions arch/arm/include/asm/vdso.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ struct mm_struct;

void arm_install_vdso(struct mm_struct *mm, unsigned long addr);

extern char vdso_start, vdso_end;

extern unsigned int vdso_total_pages;

#else /* CONFIG_VDSO */
Expand Down
12 changes: 7 additions & 5 deletions arch/arm/kernel/vdso.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

static struct page **vdso_text_pagelist;

extern char vdso_start[], vdso_end[];

/* Total number of pages needed for the data and text portions of the VDSO. */
unsigned int vdso_total_pages __ro_after_init;

Expand Down Expand Up @@ -197,13 +199,13 @@ static int __init vdso_init(void)
unsigned int text_pages;
int i;

if (memcmp(&vdso_start, "\177ELF", 4)) {
if (memcmp(vdso_start, "\177ELF", 4)) {
pr_err("VDSO is not a valid ELF object!\n");
return -ENOEXEC;
}

text_pages = (&vdso_end - &vdso_start) >> PAGE_SHIFT;
pr_debug("vdso: %i text pages at base %p\n", text_pages, &vdso_start);
text_pages = (vdso_end - vdso_start) >> PAGE_SHIFT;
pr_debug("vdso: %i text pages at base %p\n", text_pages, vdso_start);

/* Allocate the VDSO text pagelist */
vdso_text_pagelist = kcalloc(text_pages, sizeof(struct page *),
Expand All @@ -218,7 +220,7 @@ static int __init vdso_init(void)
for (i = 0; i < text_pages; i++) {
struct page *page;

page = virt_to_page(&vdso_start + i * PAGE_SIZE);
page = virt_to_page(vdso_start + i * PAGE_SIZE);
vdso_text_pagelist[i] = page;
}

Expand All @@ -229,7 +231,7 @@ static int __init vdso_init(void)

cntvct_ok = cntvct_functional();

patch_vdso(&vdso_start);
patch_vdso(vdso_start);

return 0;
}
Expand Down

0 comments on commit 73b9160

Please sign in to comment.