1/*- 2 * Copyright (c) 1994-1996 S��ren Schmidt 3 * All rights reserved. 4 * 5 * Based heavily on /sys/kern/imgact_aout.c which is: 6 * Copyright (c) 1993, David Greenman 7 * 8 * Redistribution and use in source and binary forms, with or without --- 16 unchanged lines hidden (view full) --- 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/i386/linux/imgact_linux.c 231885 2012-02-17 23:47:16Z kib $"); |
34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/exec.h> 38#include <sys/imgact.h> 39#include <sys/imgact_aout.h> 40#include <sys/kernel.h> 41#include <sys/lock.h> --- 17 unchanged lines hidden (view full) --- 59 60static int 61exec_linux_imgact(struct image_params *imgp) 62{ 63 const struct exec *a_out = (const struct exec *) imgp->image_header; 64 struct vmspace *vmspace; 65 vm_offset_t vmaddr; 66 unsigned long virtual_offset, file_offset; |
67 unsigned long bss_size; |
68 ssize_t aresid; |
69 int error; 70 71 if (((a_out->a_magic >> 16) & 0xff) != 0x64) 72 return -1; 73 74 /* 75 * Set file/virtual offset based on a.out variant. 76 */ --- 62 unchanged lines hidden (view full) --- 139 */ 140 vmaddr = virtual_offset; 141 error = vm_map_find(&vmspace->vm_map, NULL, 0, &vmaddr, 142 a_out->a_text + a_out->a_data + bss_size, FALSE, 143 VM_PROT_ALL, VM_PROT_ALL, 0); 144 if (error) 145 goto fail; 146 |
147 error = vn_rdwr(UIO_READ, imgp->vp, (void *)vmaddr, file_offset, 148 a_out->a_text + a_out->a_data, UIO_USERSPACE, 0, 149 curthread->td_ucred, NOCRED, &aresid, curthread); 150 if (error != 0) 151 goto fail; 152 if (aresid != 0) { 153 error = ENOEXEC; 154 goto fail; 155 } |
156 |
157 /* 158 * remove write enable on the 'text' part 159 */ 160 error = vm_map_protect(&vmspace->vm_map, 161 vmaddr, 162 vmaddr + a_out->a_text, 163 VM_PROT_EXECUTE|VM_PROT_READ, 164 TRUE); --- 75 unchanged lines hidden --- |