svn commit: r365715 - stable/12/sys/kern
Konstantin Belousov
kib at FreeBSD.org
Mon Sep 14 11:01:47 UTC 2020
Author: kib
Date: Mon Sep 14 11:01:46 2020
New Revision: 365715
URL: https://svnweb.freebsd.org/changeset/base/365715
Log:
MFC r365433:
imgact_elf.c: unify check for phdr fitting into the first page.
Modified:
stable/12/sys/kern/imgact_elf.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/kern/imgact_elf.c
==============================================================================
--- stable/12/sys/kern/imgact_elf.c Mon Sep 14 10:49:38 2020 (r365714)
+++ stable/12/sys/kern/imgact_elf.c Mon Sep 14 11:01:46 2020 (r365715)
@@ -438,6 +438,13 @@ __elfN(get_brandinfo)(struct image_params *imgp, const
return (NULL);
}
+static bool
+__elfN(phdr_in_zero_page)(const Elf_Ehdr *hdr)
+{
+ return (hdr->e_phoff <= PAGE_SIZE &&
+ (u_int)hdr->e_phentsize * hdr->e_phnum <= PAGE_SIZE - hdr->e_phoff);
+}
+
static int
__elfN(check_header)(const Elf_Ehdr *hdr)
{
@@ -803,8 +810,7 @@ __elfN(load_file)(struct proc *p, const char *file, u_
}
/* Only support headers that fit within first page for now */
- if ((hdr->e_phoff > PAGE_SIZE) ||
- (u_int)hdr->e_phentsize * hdr->e_phnum > PAGE_SIZE - hdr->e_phoff) {
+ if (!__elfN(phdr_in_zero_page)(hdr)) {
error = ENOEXEC;
goto fail;
}
@@ -1080,9 +1086,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i
* detected an ELF file.
*/
- if ((hdr->e_phoff > PAGE_SIZE) ||
- (u_int)hdr->e_phentsize * hdr->e_phnum > PAGE_SIZE - hdr->e_phoff) {
- /* Only support headers in first page for now */
+ if (!__elfN(phdr_in_zero_page)(hdr)) {
uprintf("Program headers not in the first page\n");
return (ENOEXEC);
}
More information about the svn-src-all
mailing list