mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-30 08:43:23 +00:00
Linux allows to mmap annonymous with a file descriptor passed, FreeBSD
doesn't. In the Linux emulation layer, ignore the fd passed when MAP_ANON is specified. Known application to be fixed: Xanalys/Harlequin Lispworks Also improve debug output for mmap, now showing what the emulation layer mapped to what (-DDEBUG). Reviewed by: marcel
This commit is contained in:
parent
7d02379e48
commit
6f6b2cd019
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=61702
@ -696,7 +696,7 @@ linux_mmap(struct proc *p, struct linux_mmap_args *args)
|
||||
sizeof(linux_args))))
|
||||
return error;
|
||||
#ifdef DEBUG
|
||||
printf("Linux-emul(%ld): mmap(%p, %d, %d, %08x, %d, %d)\n",
|
||||
printf("Linux-emul(%ld): mmap(%p, %d, %d, 0x%08x, %d, %d)",
|
||||
(long)p->p_pid, (void *)linux_args.addr, linux_args.len,
|
||||
linux_args.prot, linux_args.flags, linux_args.fd, linux_args.pos);
|
||||
#endif
|
||||
@ -756,9 +756,17 @@ linux_mmap(struct proc *p, struct linux_mmap_args *args)
|
||||
}
|
||||
|
||||
bsd_args.prot = linux_args.prot | PROT_READ; /* always required */
|
||||
bsd_args.fd = linux_args.fd;
|
||||
if (linux_args.flags & LINUX_MAP_ANON)
|
||||
bsd_args.fd = -1;
|
||||
else
|
||||
bsd_args.fd = linux_args.fd;
|
||||
bsd_args.pos = linux_args.pos;
|
||||
bsd_args.pad = 0;
|
||||
#ifdef DEBUG
|
||||
printf("-> (%p, %d, %d, 0x%08x, %d, %d)\n",
|
||||
(void *)bsd_args.addr, bsd_args.len,
|
||||
bsd_args.prot, bsd_args.flags, bsd_args.fd, (int)bsd_args.pos);
|
||||
#endif
|
||||
return mmap(p, &bsd_args);
|
||||
}
|
||||
|
||||
|
@ -696,7 +696,7 @@ linux_mmap(struct proc *p, struct linux_mmap_args *args)
|
||||
sizeof(linux_args))))
|
||||
return error;
|
||||
#ifdef DEBUG
|
||||
printf("Linux-emul(%ld): mmap(%p, %d, %d, %08x, %d, %d)\n",
|
||||
printf("Linux-emul(%ld): mmap(%p, %d, %d, 0x%08x, %d, %d)",
|
||||
(long)p->p_pid, (void *)linux_args.addr, linux_args.len,
|
||||
linux_args.prot, linux_args.flags, linux_args.fd, linux_args.pos);
|
||||
#endif
|
||||
@ -756,9 +756,17 @@ linux_mmap(struct proc *p, struct linux_mmap_args *args)
|
||||
}
|
||||
|
||||
bsd_args.prot = linux_args.prot | PROT_READ; /* always required */
|
||||
bsd_args.fd = linux_args.fd;
|
||||
if (linux_args.flags & LINUX_MAP_ANON)
|
||||
bsd_args.fd = -1;
|
||||
else
|
||||
bsd_args.fd = linux_args.fd;
|
||||
bsd_args.pos = linux_args.pos;
|
||||
bsd_args.pad = 0;
|
||||
#ifdef DEBUG
|
||||
printf("-> (%p, %d, %d, 0x%08x, %d, %d)\n",
|
||||
(void *)bsd_args.addr, bsd_args.len,
|
||||
bsd_args.prot, bsd_args.flags, bsd_args.fd, (int)bsd_args.pos);
|
||||
#endif
|
||||
return mmap(p, &bsd_args);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user