Use address space guard to implement inter-segment gap.
Rtld checks and use old MAP_ANON/PROT_NONE method of creating gap if running on old kernel. Reviewed by: alc, markj Tested by: pho, Qualys Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
19bd0d9c85
commit
a36deee3d3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=320318
@ -41,6 +41,8 @@
|
|||||||
static Elf_Ehdr *get_elf_header(int, const char *, const struct stat *);
|
static Elf_Ehdr *get_elf_header(int, const char *, const struct stat *);
|
||||||
static int convert_flags(int); /* Elf flags -> mmap flags */
|
static int convert_flags(int); /* Elf flags -> mmap flags */
|
||||||
|
|
||||||
|
int __getosreldate(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map a shared object into memory. The "fd" argument is a file descriptor,
|
* Map a shared object into memory. The "fd" argument is a file descriptor,
|
||||||
* which must be open on the object and positioned at its beginning.
|
* which must be open on the object and positioned at its beginning.
|
||||||
@ -190,7 +192,8 @@ map_object(int fd, const char *path, const struct stat *sb)
|
|||||||
base_vlimit = round_page(segs[nsegs]->p_vaddr + segs[nsegs]->p_memsz);
|
base_vlimit = round_page(segs[nsegs]->p_vaddr + segs[nsegs]->p_memsz);
|
||||||
mapsize = base_vlimit - base_vaddr;
|
mapsize = base_vlimit - base_vaddr;
|
||||||
base_addr = (caddr_t) base_vaddr;
|
base_addr = (caddr_t) base_vaddr;
|
||||||
base_flags = MAP_PRIVATE | MAP_ANON | MAP_NOCORE;
|
base_flags = __getosreldate() >= P_OSREL_MAP_GUARD ? MAP_GUARD :
|
||||||
|
MAP_PRIVATE | MAP_ANON | MAP_NOCORE;
|
||||||
if (npagesizes > 1 && round_page(segs[0]->p_filesz) >= pagesizes[1])
|
if (npagesizes > 1 && round_page(segs[0]->p_filesz) >= pagesizes[1])
|
||||||
base_flags |= MAP_ALIGNED_SUPER;
|
base_flags |= MAP_ALIGNED_SUPER;
|
||||||
if (base_vaddr != 0)
|
if (base_vaddr != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user