Better fit with SELinux. Now requires only execmem, which Fedora Core 5
enables as default for non-confined [ordinary] executables. l_lx_elf.c l_lx_elf86.asm l_lx_elf86.h l_lx_elf86.lds fold_elf86.asm fold_elf86.h committer: jreiser <jreiser> 1145634453 +0000
This commit is contained in:
+15
-13
@@ -90,8 +90,6 @@ err_exit(int a) __attribute__ ((__noreturn__));
|
||||
}
|
||||
#endif //}
|
||||
|
||||
extern void die_SELinux();
|
||||
|
||||
static void *
|
||||
do_brk(void *addr)
|
||||
{
|
||||
@@ -270,9 +268,9 @@ xfind_pages(unsigned mflags, Elf32_Phdr const *phdr, int phnum,
|
||||
lo -= ~PAGE_MASK & lo; // round down to page boundary
|
||||
hi = PAGE_MASK & (hi - lo - PAGE_MASK -1); // page length
|
||||
szlo = PAGE_MASK & (szlo - PAGE_MASK -1); // page length
|
||||
addr = mmap((void *)lo, hi, PROT_NONE, mflags, -1, 0 ); // just reserve address space
|
||||
addr = mmap((void *)lo, hi, PROT_NONE, mflags, -1, 0);
|
||||
*p_brk = hi + addr; // the logical value of brk(0)
|
||||
munmap(szlo + addr, hi - szlo); // desirable if PT_LOAD non-contiguous
|
||||
//mprotect(szlo + addr, hi - szlo, PROT_NONE); // no access, but keep the frames!
|
||||
return (unsigned long)addr - lo;
|
||||
}
|
||||
|
||||
@@ -301,29 +299,33 @@ do_xmap(int const fdi, Elf32_Ehdr const *const ehdr, struct Extent *const xi,
|
||||
addr -= frag;
|
||||
|
||||
// Decompressor can overrun the destination by 3 bytes.
|
||||
if (addr != mmap(addr, mlen + (xi ? 3 : 0), PROT_READ | PROT_WRITE,
|
||||
if (addr != mmap(addr, mlen + (xi ? 3 : 0), prot | (xi ? PROT_WRITE : 0),
|
||||
MAP_FIXED | MAP_PRIVATE | (xi ? MAP_ANONYMOUS : 0),
|
||||
fdi, phdr->p_offset - frag) ) {
|
||||
(xi ? -1 : fdi), phdr->p_offset - frag) ) {
|
||||
err_exit(8);
|
||||
}
|
||||
if (xi) {
|
||||
unpackExtent(xi, &xo, (f_expand *)fdi,
|
||||
((phdr->p_flags & PF_X) ? (f_unfilter *)(2+ fdi) : 0));
|
||||
((PROT_EXEC & prot) ? (f_unfilter *)(2+ fdi) : 0));
|
||||
}
|
||||
bzero(addr, frag); // fragment at lo end
|
||||
// Linux does not fixup the low end, so neither do we.
|
||||
//if (PROT_WRITE & prot) {
|
||||
// bzero(addr, frag); // fragment at lo end
|
||||
//}
|
||||
frag = (-mlen) &~ PAGE_MASK; // distance to next page boundary
|
||||
bzero(mlen+addr, frag); // fragment at hi end
|
||||
if (PROT_WRITE & prot) { // note: read-only .bss not supported here
|
||||
bzero(mlen+addr, frag); // fragment at hi end
|
||||
}
|
||||
if (xi) {
|
||||
void *const hatch = make_hatch(phdr, reloc);
|
||||
if (0!=hatch) {
|
||||
/* always update AT_NULL, especially for compressed PT_INTERP */
|
||||
auxv_up((Elf32_auxv_t *)(~1 & (int)av), AT_NULL, (unsigned)hatch);
|
||||
}
|
||||
}
|
||||
if (0!=mprotect(addr, mlen, prot)) {
|
||||
die_SELinux();
|
||||
err_exit(10);
|
||||
if (0!=mprotect(addr, mlen, prot)) {
|
||||
err_exit(10);
|
||||
ERR_LAB
|
||||
}
|
||||
}
|
||||
addr += mlen + frag; /* page boundary on hi end */
|
||||
if (addr < haddr) { // need pages for .bss
|
||||
|
||||
Reference in New Issue
Block a user