Deleted Added
full compact
imgact_linux.c (230132) imgact_linux.c (231885)
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>
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 230132 2012-01-15 13:23:18Z uqs $");
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;
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 vm_offset_t buffer;
68 unsigned long bss_size;
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
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 = vm_mmap(kernel_map, &buffer,
148 round_page(a_out->a_text + a_out->a_data + file_offset),
149 VM_PROT_READ, VM_PROT_READ, 0, OBJT_VNODE,
150 imgp->vp, trunc_page(file_offset));
151 if (error)
152 goto fail;
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 }
153
156
154 error = copyout((void *)(uintptr_t)(buffer + file_offset),
155 (void *)vmaddr, a_out->a_text + a_out->a_data);
156
157 vm_map_remove(kernel_map, buffer,
158 buffer + round_page(a_out->a_text + a_out->a_data + file_offset));
159
160 if (error)
161 goto fail;
162
163 /*
164 * remove write enable on the 'text' part
165 */
166 error = vm_map_protect(&vmspace->vm_map,
167 vmaddr,
168 vmaddr + a_out->a_text,
169 VM_PROT_EXECUTE|VM_PROT_READ,
170 TRUE);

--- 75 unchanged lines hidden ---
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 ---