1/*- 2 * Copyright (c) 2002 Doug Rabson 3 * Copyright (c) 1994-1995 S��ren Schmidt 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 14 unchanged lines hidden (view full) --- 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/compat/linux/linux_misc.c 231885 2012-02-17 23:47:16Z kib $"); |
32 33#include "opt_compat.h" 34 35#include <sys/param.h> 36#include <sys/blist.h> 37#include <sys/fcntl.h> 38#if defined(__i386__) 39#include <sys/imgact_aout.h> --- 184 unchanged lines hidden (view full) --- 224linux_uselib(struct thread *td, struct linux_uselib_args *args) 225{ 226 struct nameidata ni; 227 struct vnode *vp; 228 struct exec *a_out; 229 struct vattr attr; 230 vm_offset_t vmaddr; 231 unsigned long file_offset; |
232 unsigned long bss_size; 233 char *library; |
234 ssize_t aresid; |
235 int error; 236 int locked, vfslocked; 237 238 LCONVPATHEXIST(td, args->library, &library); 239 240#ifdef DEBUG 241 if (ldebug(uselib)) 242 printf(ARGS(uselib, "%s"), library); --- 60 unchanged lines hidden (view full) --- 303 error = mac_vnode_check_open(td->td_ucred, vp, VREAD); 304 if (error) 305 goto cleanup; 306#endif 307 error = VOP_OPEN(vp, FREAD, td->td_ucred, td, NULL); 308 if (error) 309 goto cleanup; 310 |
311 /* Pull in executable header into exec_map */ 312 error = vm_mmap(exec_map, (vm_offset_t *)&a_out, PAGE_SIZE, |
313 VM_PROT_READ, VM_PROT_READ, 0, OBJT_VNODE, vp, 0); 314 if (error) 315 goto cleanup; 316 317 /* Is it a Linux binary ? */ 318 if (((a_out->a_magic >> 16) & 0xff) != 0x64) { 319 error = ENOEXEC; 320 goto cleanup; --- 76 unchanged lines hidden (view full) --- 397 398 /* get anon user mapping, read+write+execute */ 399 error = vm_map_find(&td->td_proc->p_vmspace->vm_map, NULL, 0, 400 &vmaddr, a_out->a_text + a_out->a_data, FALSE, VM_PROT_ALL, 401 VM_PROT_ALL, 0); 402 if (error) 403 goto cleanup; 404 |
405 error = vn_rdwr(UIO_READ, vp, (void *)vmaddr, file_offset, 406 a_out->a_text + a_out->a_data, UIO_USERSPACE, 0, 407 td->td_ucred, NOCRED, &aresid, td); 408 if (error != 0) |
409 goto cleanup; |
410 if (aresid != 0) { 411 error = ENOEXEC; |
412 goto cleanup; |
413 } |
414 } else { 415#ifdef DEBUG 416 printf("uselib: Page aligned binary %lu\n", file_offset); 417#endif 418 /* 419 * for QMAGIC, a_entry is 20 bytes beyond the load address 420 * to skip the executable header 421 */ --- 27 unchanged lines hidden (view full) --- 449 450cleanup: 451 /* Unlock vnode if needed */ 452 if (locked) { 453 VOP_UNLOCK(vp, 0); 454 VFS_UNLOCK_GIANT(vfslocked); 455 } 456 |
457 /* Release the temporary mapping. */ |
458 if (a_out) |
459 kmem_free_wakeup(exec_map, (vm_offset_t)a_out, PAGE_SIZE); |
460 461 return (error); 462} 463 464#endif /* __i386__ */ 465 466int 467linux_select(struct thread *td, struct linux_select_args *args) --- 1449 unchanged lines hidden --- |