Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1318164 > unrolled thread

[PATCH v4 15/22] scripts/sortextable: add support for ET_DYN binaries

Started byArd Biesheuvel <ard.biesheuvel@linaro.org>
First post2016-01-26 18:20 +0100
Last post2016-01-27 00:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v4 15/22] scripts/sortextable: add support for ET_DYN binaries Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-01-26 18:20 +0100
    Re: [PATCH v4 15/22] scripts/sortextable: add support for ET_DYN binaries Kees Cook <keescook@chromium.org> - 2016-01-27 00:30 +0100

#1318164 — [PATCH v4 15/22] scripts/sortextable: add support for ET_DYN binaries

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2016-01-26 18:20 +0100
Subject[PATCH v4 15/22] scripts/sortextable: add support for ET_DYN binaries
Message-ID<qVfrA-7iQ-13@gated-at.bofh.it>
Add support to scripts/sortextable for handling relocatable (PIE)
executables, whose ELF type is ET_DYN, not ET_EXEC. Other than adding
support for the new type, no changes are needed.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 scripts/sortextable.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/sortextable.c b/scripts/sortextable.c
index af247c70fb66..19d83647846c 100644
--- a/scripts/sortextable.c
+++ b/scripts/sortextable.c
@@ -266,9 +266,9 @@ do_file(char const *const fname)
 		break;
 	}  /* end switch */
 	if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0
-	||  r2(&ehdr->e_type) != ET_EXEC
+	||  (r2(&ehdr->e_type) != ET_EXEC && r2(&ehdr->e_type) != ET_DYN)
 	||  ehdr->e_ident[EI_VERSION] != EV_CURRENT) {
-		fprintf(stderr, "unrecognized ET_EXEC file %s\n", fname);
+		fprintf(stderr, "unrecognized ET_EXEC/ET_DYN file %s\n", fname);
 		fail_file();
 	}
 
@@ -304,7 +304,7 @@ do_file(char const *const fname)
 		if (r2(&ehdr->e_ehsize) != sizeof(Elf32_Ehdr)
 		||  r2(&ehdr->e_shentsize) != sizeof(Elf32_Shdr)) {
 			fprintf(stderr,
-				"unrecognized ET_EXEC file: %s\n", fname);
+				"unrecognized ET_EXEC/ET_DYN file: %s\n", fname);
 			fail_file();
 		}
 		do32(ehdr, fname, custom_sort);
@@ -314,7 +314,7 @@ do_file(char const *const fname)
 		if (r2(&ghdr->e_ehsize) != sizeof(Elf64_Ehdr)
 		||  r2(&ghdr->e_shentsize) != sizeof(Elf64_Shdr)) {
 			fprintf(stderr,
-				"unrecognized ET_EXEC file: %s\n", fname);
+				"unrecognized ET_EXEC/ET_DYN file: %s\n", fname);
 			fail_file();
 		}
 		do64(ghdr, fname, custom_sort);
-- 
2.5.0

[toc] | [next] | [standalone]


#1318464

FromKees Cook <keescook@chromium.org>
Date2016-01-27 00:30 +0100
Message-ID<qVldE-33s-1@gated-at.bofh.it>
In reply to#1318164
On Tue, Jan 26, 2016 at 9:10 AM, Ard Biesheuvel
<ard.biesheuvel@linaro.org> wrote:
> Add support to scripts/sortextable for handling relocatable (PIE)
> executables, whose ELF type is ET_DYN, not ET_EXEC. Other than adding
> support for the new type, no changes are needed.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Reviewed-by: Kees Cook <keescook@chromium.org>

Something I can actually test! :)

-Kees

> ---
>  scripts/sortextable.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/sortextable.c b/scripts/sortextable.c
> index af247c70fb66..19d83647846c 100644
> --- a/scripts/sortextable.c
> +++ b/scripts/sortextable.c
> @@ -266,9 +266,9 @@ do_file(char const *const fname)
>                 break;
>         }  /* end switch */
>         if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0
> -       ||  r2(&ehdr->e_type) != ET_EXEC
> +       ||  (r2(&ehdr->e_type) != ET_EXEC && r2(&ehdr->e_type) != ET_DYN)
>         ||  ehdr->e_ident[EI_VERSION] != EV_CURRENT) {
> -               fprintf(stderr, "unrecognized ET_EXEC file %s\n", fname);
> +               fprintf(stderr, "unrecognized ET_EXEC/ET_DYN file %s\n", fname);
>                 fail_file();
>         }
>
> @@ -304,7 +304,7 @@ do_file(char const *const fname)
>                 if (r2(&ehdr->e_ehsize) != sizeof(Elf32_Ehdr)
>                 ||  r2(&ehdr->e_shentsize) != sizeof(Elf32_Shdr)) {
>                         fprintf(stderr,
> -                               "unrecognized ET_EXEC file: %s\n", fname);
> +                               "unrecognized ET_EXEC/ET_DYN file: %s\n", fname);
>                         fail_file();
>                 }
>                 do32(ehdr, fname, custom_sort);
> @@ -314,7 +314,7 @@ do_file(char const *const fname)
>                 if (r2(&ghdr->e_ehsize) != sizeof(Elf64_Ehdr)
>                 ||  r2(&ghdr->e_shentsize) != sizeof(Elf64_Shdr)) {
>                         fprintf(stderr,
> -                               "unrecognized ET_EXEC file: %s\n", fname);
> +                               "unrecognized ET_EXEC/ET_DYN file: %s\n", fname);
>                         fail_file();
>                 }
>                 do64(ghdr, fname, custom_sort);
> --
> 2.5.0
>



-- 
Kees Cook
Chrome OS & Brillo Security

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web