diff options
author | jkim <jkim@FreeBSD.org> | 2007-02-27 02:08:01 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2007-02-27 02:08:01 +0000 |
commit | 2620bd06dafc20822c133be0bfde981dbb508814 (patch) | |
tree | 22ccf05d321d63be7964c0de304336723fedcb41 | |
parent | 287d98b31494076889395f1f1b2bfa8669d4058f (diff) | |
download | FreeBSD-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
-rw-r--r-- | sys/amd64/linux32/linux32_machdep.c | 7 | ||||
-rw-r--r-- | sys/i386/linux/linux_machdep.c | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c index ac0b9c1..7e9274f 100644 --- a/sys/amd64/linux32/linux32_machdep.c +++ b/sys/amd64/linux32/linux32_machdep.c @@ -793,7 +793,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 @@ -801,7 +803,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); @@ -816,7 +818,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) { /* 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) { /* |