Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108594769
D39594.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D39594.diff
View Options
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -924,7 +924,7 @@
static int
__elfN(enforce_limits)(struct image_params *imgp, const Elf_Ehdr *hdr,
- const Elf_Phdr *phdr, u_long et_dyn_addr)
+ const Elf_Phdr *phdr)
{
struct vmspace *vmspace;
const char *err_str;
@@ -939,9 +939,9 @@
if (phdr[i].p_type != PT_LOAD || phdr[i].p_memsz == 0)
continue;
- seg_addr = trunc_page(phdr[i].p_vaddr + et_dyn_addr);
+ seg_addr = trunc_page(phdr[i].p_vaddr + imgp->et_dyn_addr);
seg_size = round_page(phdr[i].p_memsz +
- phdr[i].p_vaddr + et_dyn_addr - seg_addr);
+ phdr[i].p_vaddr + imgp->et_dyn_addr - seg_addr);
/*
* Make the largest executable segment the official
@@ -1106,7 +1106,7 @@
char *interp;
Elf_Brandinfo *brand_info;
struct sysentvec *sv;
- u_long addr, baddr, et_dyn_addr, entry, proghdr;
+ u_long addr, baddr, entry, proghdr;
u_long maxalign, maxsalign, mapsz, maxv, maxv1, anon_loc;
uint32_t fctl0;
int32_t osrel;
@@ -1235,7 +1235,6 @@
goto ret;
}
sv = brand_info->sysvec;
- et_dyn_addr = 0;
if (hdr->e_type == ET_DYN) {
if ((brand_info->flags & BI_CAN_EXEC_DYN) == 0) {
uprintf("Cannot execute shared object\n");
@@ -1249,13 +1248,13 @@
if (baddr == 0) {
if ((sv->sv_flags & SV_ASLR) == 0 ||
(fctl0 & NT_FREEBSD_FCTL_ASLR_DISABLE) != 0)
- et_dyn_addr = __elfN(pie_base);
+ imgp->et_dyn_addr = __elfN(pie_base);
else if ((__elfN(pie_aslr_enabled) &&
(imgp->proc->p_flag2 & P2_ASLR_DISABLE) == 0) ||
(imgp->proc->p_flag2 & P2_ASLR_ENABLE) != 0)
- et_dyn_addr = ET_DYN_ADDR_RAND;
+ imgp->et_dyn_addr = ET_DYN_ADDR_RAND;
else
- et_dyn_addr = __elfN(pie_base);
+ imgp->et_dyn_addr = __elfN(pie_base);
}
}
@@ -1288,11 +1287,11 @@
if ((sv->sv_flags & SV_ASLR) == 0 ||
(imgp->proc->p_flag2 & P2_ASLR_DISABLE) != 0 ||
(fctl0 & NT_FREEBSD_FCTL_ASLR_DISABLE) != 0) {
- KASSERT(et_dyn_addr != ET_DYN_ADDR_RAND,
- ("et_dyn_addr == RAND and !ASLR"));
+ KASSERT(imgp->et_dyn_addr != ET_DYN_ADDR_RAND,
+ ("imgp->et_dyn_addr == RAND and !ASLR"));
} else if ((imgp->proc->p_flag2 & P2_ASLR_ENABLE) != 0 ||
(__elfN(aslr_enabled) && hdr->e_type == ET_EXEC) ||
- et_dyn_addr == ET_DYN_ADDR_RAND) {
+ imgp->et_dyn_addr == ET_DYN_ADDR_RAND) {
imgp->map_flags |= MAP_ASLR;
/*
* If user does not care about sbrk, utilize the bss
@@ -1329,24 +1328,24 @@
error = ENOEXEC;
}
- if (error == 0 && et_dyn_addr == ET_DYN_ADDR_RAND) {
+ if (error == 0 && imgp->et_dyn_addr == ET_DYN_ADDR_RAND) {
KASSERT((map->flags & MAP_ASLR) != 0,
("ET_DYN_ADDR_RAND but !MAP_ASLR"));
error = __CONCAT(rnd_, __elfN(base))(map,
vm_map_min(map) + mapsz + lim_max(td, RLIMIT_DATA),
/* reserve half of the address space to interpreter */
- maxv / 2, maxalign, &et_dyn_addr);
+ maxv / 2, maxalign, &imgp->et_dyn_addr);
}
vn_lock(imgp->vp, LK_SHARED | LK_RETRY);
if (error != 0)
goto ret;
- error = __elfN(load_sections)(imgp, hdr, phdr, et_dyn_addr, NULL);
+ error = __elfN(load_sections)(imgp, hdr, phdr, imgp->et_dyn_addr, NULL);
if (error != 0)
goto ret;
- error = __elfN(enforce_limits)(imgp, hdr, phdr, et_dyn_addr);
+ error = __elfN(enforce_limits)(imgp, hdr, phdr);
if (error != 0)
goto ret;
@@ -1370,7 +1369,7 @@
map->anon_loc = addr;
}
- entry = (u_long)hdr->e_entry + et_dyn_addr;
+ entry = (u_long)hdr->e_entry + imgp->et_dyn_addr;
imgp->entry_addr = entry;
if (interp != NULL) {
@@ -1389,7 +1388,7 @@
if (error != 0)
goto ret;
} else
- addr = et_dyn_addr;
+ addr = imgp->et_dyn_addr;
error = exec_map_stack(imgp);
if (error != 0)
@@ -1405,7 +1404,7 @@
vn_lock(imgp->vp, LK_SHARED | LK_RETRY);
}
elf_auxargs->execfd = -1;
- elf_auxargs->phdr = proghdr + et_dyn_addr;
+ elf_auxargs->phdr = proghdr + imgp->et_dyn_addr;
elf_auxargs->phent = hdr->e_phentsize;
elf_auxargs->phnum = hdr->e_phnum;
elf_auxargs->pagesz = PAGE_SIZE;
diff --git a/sys/sys/imgact.h b/sys/sys/imgact.h
--- a/sys/sys/imgact.h
+++ b/sys/sys/imgact.h
@@ -66,6 +66,7 @@
const char *image_header; /* header of file to exec */
unsigned long entry_addr; /* entry address of target executable */
unsigned long reloc_base; /* load address of image */
+ unsigned long et_dyn_addr; /* PIE load base */
char *interpreter_name; /* name of the interpreter */
void *auxargs; /* ELF Auxinfo structure pointer */
struct sf_buf *firstpage; /* first page that we mapped */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 27, 6:21 PM (6 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16203968
Default Alt Text
D39594.diff (4 KB)
Attached To
Mode
D39594: imgact: Make et_dyn_addr part of image_params
Attached
Detach File
Event Timeline
Log In to Comment