summaryrefslogtreecommitdiffstats
path: root/sys/i386
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2007-02-27 02:08:01 +0000
committerjkim <jkim@FreeBSD.org>2007-02-27 02:08:01 +0000
commit2620bd06dafc20822c133be0bfde981dbb508814 (patch)
tree22ccf05d321d63be7964c0de304336723fedcb41 /sys/i386
parent287d98b31494076889395f1f1b2bfa8669d4058f (diff)
downloadFreeBSD-src-2620bd06dafc20822c133be0bfde981dbb508814.zip
FreeBSD-src-2620bd06dafc20822c133be0bfde981dbb508814.tar.gz
MFP4: 115094
Linux does not check file descriptor when MAP_ANONYMOUS is set. This should fix recent LTP test regressions. Reported by: Scot Hetzel (swhetzel at gmail dot com) netchild
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/linux/linux_machdep.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c
index 83aa0d3..9f7eb18 100644
--- a/sys/i386/linux/linux_machdep.c
+++ b/sys/i386/linux/linux_machdep.c
@@ -684,7 +684,9 @@ linux_mmap_common(struct thread *td, struct l_mmap_argv *linux_args)
if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
bsd_args.prot |= PROT_READ | PROT_EXEC;
- if (linux_args->fd != -1) {
+ /* Linux does not check file descriptor when MAP_ANONYMOUS is set. */
+ bsd_args.fd = (bsd_args.flags & MAP_ANON) ? -1 : linux_args->fd;
+ if (bsd_args.fd != -1) {
/*
* Linux follows Solaris mmap(2) description:
* The file descriptor fildes is opened with
@@ -692,7 +694,7 @@ linux_mmap_common(struct thread *td, struct l_mmap_argv *linux_args)
* protection options specified.
*/
- if ((error = fget(td, linux_args->fd, &fp)) != 0)
+ if ((error = fget(td, bsd_args.fd, &fp)) != 0)
return (error);
if (fp->f_type != DTYPE_VNODE) {
fdrop(fp, td);
@@ -707,7 +709,6 @@ linux_mmap_common(struct thread *td, struct l_mmap_argv *linux_args)
fdrop(fp, td);
}
- bsd_args.fd = linux_args->fd;
if (linux_args->flags & LINUX_MAP_GROWSDOWN) {
/*
OpenPOWER on IntegriCloud