Skip to content

Commit

Permalink
Add generic sys_old_mmap()
Browse files Browse the repository at this point in the history
Add a generic implementation of the old mmap() syscall, which expects its
argument in a memory block and switch all architectures over to use it.

Signed-off-by: Christoph Hellwig <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: Jeff Dike <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Reviewed-by: H. Peter Anvin <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: "Luck, Tony" <[email protected]>
Cc: James Morris <[email protected]>
Cc: Andreas Schwab <[email protected]>
Acked-by: Jesper Nilsson <[email protected]>
Acked-by: Russell King <[email protected]>
Acked-by: Greg Ungerer <[email protected]>
Acked-by: David Howells <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Christoph Hellwig authored and torvalds committed Mar 12, 2010
1 parent 5d0e528 commit a467937
Show file tree
Hide file tree
Showing 31 changed files with 79 additions and 258 deletions.
1 change: 1 addition & 0 deletions arch/arm/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@
#define __ARCH_WANT_SYS_SIGPROCMASK
#define __ARCH_WANT_SYS_RT_SIGACTION
#define __ARCH_WANT_SYS_RT_SIGSUSPEND
#define __ARCH_WANT_SYS_OLD_MMAP
#define __ARCH_WANT_SYS_OLD_SELECT

#if !defined(CONFIG_AEABI) || defined(CONFIG_OABI_COMPAT)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/kernel/calls.S
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
CALL(sys_swapon)
CALL(sys_reboot)
CALL(OBSOLETE(sys_old_readdir)) /* used by libc4 */
/* 90 */ CALL(OBSOLETE(old_mmap)) /* used by libc4 */
/* 90 */ CALL(OBSOLETE(sys_old_mmap)) /* used by libc4 */
CALL(sys_munmap)
CALL(sys_truncate)
CALL(sys_ftruncate)
Expand Down
26 changes: 0 additions & 26 deletions arch/arm/kernel/sys_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,6 @@
#include <linux/ipc.h>
#include <linux/uaccess.h>

struct mmap_arg_struct {
unsigned long addr;
unsigned long len;
unsigned long prot;
unsigned long flags;
unsigned long fd;
unsigned long offset;
};

asmlinkage int old_mmap(struct mmap_arg_struct __user *arg)
{
int error = -EFAULT;
struct mmap_arg_struct a;

if (copy_from_user(&a, arg, sizeof(a)))
goto out;

error = -EINVAL;
if (a.offset & ~PAGE_MASK)
goto out;

error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
out:
return error;
}

#if !defined(CONFIG_AEABI) || defined(CONFIG_OABI_COMPAT)
/*
* sys_ipc() is the de-multiplexer for the SysV IPC calls..
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v10/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ sys_call_table:
.long sys_swapon
.long sys_reboot
.long sys_old_readdir
.long old_mmap /* 90 */
.long sys_old_mmap /* 90 */
.long sys_munmap
.long sys_truncate
.long sys_ftruncate
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v32/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ sys_call_table:
.long sys_swapon
.long sys_reboot
.long sys_old_readdir
.long old_mmap /* 90 */
.long sys_old_mmap /* 90 */
.long sys_munmap
.long sys_truncate
.long sys_ftruncate
Expand Down
1 change: 1 addition & 0 deletions arch/cris/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_MMAP
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK
Expand Down
18 changes: 0 additions & 18 deletions arch/cris/kernel/sys_cris.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,6 @@
#include <asm/uaccess.h>
#include <asm/segment.h>

asmlinkage unsigned long old_mmap(unsigned long __user *args)
{
unsigned long buffer[6];
int err = -EFAULT;

if (copy_from_user(&buffer, args, sizeof(buffer)))
goto out;

err = -EINVAL;
if (buffer[5] & ~PAGE_MASK) /* verify that offset is on page boundary */
goto out;

err = sys_mmap_pgoff(buffer[0], buffer[1], buffer[2], buffer[3],
buffer[4], buffer[5] >> PAGE_SHIFT);
out:
return err;
}

asmlinkage long
sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
unsigned long flags, unsigned long fd, unsigned long pgoff)
Expand Down
1 change: 1 addition & 0 deletions arch/h8300/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_MMAP
#define __ARCH_WANT_SYS_OLD_SELECT
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
Expand Down
34 changes: 0 additions & 34 deletions arch/h8300/kernel/sys_h8300.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,6 @@
#include <asm/traps.h>
#include <asm/unistd.h>

/*
* Perform the select(nd, in, out, ex, tv) and mmap() system
* calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
* handle more than 4 system call parameters, so these system calls
* used a memory block for parameter passing..
*/

struct mmap_arg_struct {
unsigned long addr;
unsigned long len;
unsigned long prot;
unsigned long flags;
unsigned long fd;
unsigned long offset;
};

asmlinkage int old_mmap(struct mmap_arg_struct *arg)
{
struct mmap_arg_struct a;
int error = -EFAULT;

if (copy_from_user(&a, arg, sizeof(a)))
goto out;

error = -EINVAL;
if (a.offset & ~PAGE_MASK)
goto out;

error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
a.offset >> PAGE_SHIFT);
out:
return error;
}

/*
* sys_ipc() is the de-multiplexer for the SysV IPC calls..
*
Expand Down
2 changes: 1 addition & 1 deletion arch/h8300/kernel/syscalls.S
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ SYMBOL_NAME_LABEL(sys_call_table)
.long SYMBOL_NAME(sys_swapon)
.long SYMBOL_NAME(sys_reboot)
.long SYMBOL_NAME(sys_old_readdir)
.long SYMBOL_NAME(old_mmap) /* 90 */
.long SYMBOL_NAME(sys_old_mmap) /* 90 */
.long SYMBOL_NAME(sys_munmap)
.long SYMBOL_NAME(sys_truncate)
.long SYMBOL_NAME(sys_ftruncate)
Expand Down
1 change: 1 addition & 0 deletions arch/m68k/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_MMAP
#define __ARCH_WANT_SYS_OLD_SELECT
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
Expand Down
2 changes: 1 addition & 1 deletion arch/m68k/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ sys_call_table:
.long sys_swapon
.long sys_reboot
.long sys_old_readdir
.long old_mmap /* 90 */
.long sys_old_mmap /* 90 */
.long sys_munmap
.long sys_truncate
.long sys_ftruncate
Expand Down
34 changes: 0 additions & 34 deletions arch/m68k/kernel/sys_m68k.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,40 +46,6 @@ asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
}

/*
* Perform the select(nd, in, out, ex, tv) and mmap() system
* calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
* handle more than 4 system call parameters, so these system calls
* used a memory block for parameter passing..
*/

struct mmap_arg_struct {
unsigned long addr;
unsigned long len;
unsigned long prot;
unsigned long flags;
unsigned long fd;
unsigned long offset;
};

asmlinkage int old_mmap(struct mmap_arg_struct __user *arg)
{
struct mmap_arg_struct a;
int error = -EFAULT;

if (copy_from_user(&a, arg, sizeof(a)))
goto out;

error = -EINVAL;
if (a.offset & ~PAGE_MASK)
goto out;

error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
a.offset >> PAGE_SHIFT);
out:
return error;
}

/*
* sys_ipc() is the de-multiplexer for the SysV IPC calls..
*
Expand Down
34 changes: 0 additions & 34 deletions arch/m68knommu/kernel/sys_m68k.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,6 @@
#include <asm/cacheflush.h>
#include <asm/unistd.h>

/*
* Perform the select(nd, in, out, ex, tv) and mmap() system
* calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
* handle more than 4 system call parameters, so these system calls
* used a memory block for parameter passing..
*/

struct mmap_arg_struct {
unsigned long addr;
unsigned long len;
unsigned long prot;
unsigned long flags;
unsigned long fd;
unsigned long offset;
};

asmlinkage int old_mmap(struct mmap_arg_struct *arg)
{
struct mmap_arg_struct a;
int error = -EFAULT;

if (copy_from_user(&a, arg, sizeof(a)))
goto out;

error = -EINVAL;
if (a.offset & ~PAGE_MASK)
goto out;

error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
a.offset >> PAGE_SHIFT);
out:
return error;
}

/*
* sys_ipc() is the de-multiplexer for the SysV IPC calls..
*
Expand Down
2 changes: 1 addition & 1 deletion arch/m68knommu/kernel/syscalltable.S
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ ENTRY(sys_call_table)
.long sys_ni_syscall /* sys_swapon */
.long sys_reboot
.long sys_old_readdir
.long old_mmap /* 90 */
.long sys_old_mmap /* 90 */
.long sys_munmap
.long sys_truncate
.long sys_ftruncate
Expand Down
1 change: 1 addition & 0 deletions arch/s390/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_MMAP
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK
Expand Down
5 changes: 2 additions & 3 deletions arch/s390/kernel/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ void __init startup_init(void);
void die(const char * str, struct pt_regs * regs, long err);

struct new_utsname;
struct mmap_arg_struct;
struct s390_mmap_arg_struct;
struct fadvise64_64_args;
struct old_sigaction;

long sys_mmap2(struct mmap_arg_struct __user *arg);
long sys_s390_old_mmap(struct mmap_arg_struct __user *arg);
long sys_mmap2(struct s390_mmap_arg_struct __user *arg);
long sys_ipc(uint call, int first, unsigned long second,
unsigned long third, void __user *ptr);
long sys_s390_newuname(struct new_utsname __user *name);
Expand Down
30 changes: 6 additions & 24 deletions arch/s390/kernel/sys_s390.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@
#include "entry.h"

/*
* Perform the select(nd, in, out, ex, tv) and mmap() system
* calls. Linux for S/390 isn't able to handle more than 5
* system call parameters, so these system calls used a memory
* block for parameter passing..
* Perform the mmap() system call. Linux for S/390 isn't able to handle more
* than 5 system call parameters, so this system call uses a memory block
* for parameter passing.
*/

struct mmap_arg_struct {
struct s390_mmap_arg_struct {
unsigned long addr;
unsigned long len;
unsigned long prot;
Expand All @@ -48,9 +47,9 @@ struct mmap_arg_struct {
unsigned long offset;
};

SYSCALL_DEFINE1(mmap2, struct mmap_arg_struct __user *, arg)
SYSCALL_DEFINE1(mmap2, struct s390_mmap_arg_struct __user *, arg)
{
struct mmap_arg_struct a;
struct s390_mmap_arg_struct a;
int error = -EFAULT;

if (copy_from_user(&a, arg, sizeof(a)))
Expand All @@ -60,23 +59,6 @@ SYSCALL_DEFINE1(mmap2, struct mmap_arg_struct __user *, arg)
return error;
}

SYSCALL_DEFINE1(s390_old_mmap, struct mmap_arg_struct __user *, arg)
{
struct mmap_arg_struct a;
long error = -EFAULT;

if (copy_from_user(&a, arg, sizeof(a)))
goto out;

error = -EINVAL;
if (a.offset & ~PAGE_MASK)
goto out;

error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
out:
return error;
}

/*
* sys_ipc() is the de-multiplexer for the SysV IPC calls..
*
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/kernel/syscalls.S
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ SYSCALL(sys_uselib,sys_uselib,sys32_uselib_wrapper)
SYSCALL(sys_swapon,sys_swapon,sys32_swapon_wrapper)
SYSCALL(sys_reboot,sys_reboot,sys32_reboot_wrapper)
SYSCALL(sys_ni_syscall,sys_ni_syscall,old32_readdir_wrapper) /* old readdir syscall */
SYSCALL(sys_s390_old_mmap,sys_s390_old_mmap,old32_mmap_wrapper) /* 90 */
SYSCALL(sys_old_mmap,sys_old_mmap,old32_mmap_wrapper) /* 90 */
SYSCALL(sys_munmap,sys_munmap,sys32_munmap_wrapper)
SYSCALL(sys_truncate,sys_truncate,sys32_truncate_wrapper)
SYSCALL(sys_ftruncate,sys_ftruncate,sys32_ftruncate_wrapper)
Expand Down
2 changes: 0 additions & 2 deletions arch/um/sys-i386/shared/sysdep/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ typedef long syscall_handler_t(struct pt_regs);
*/
extern syscall_handler_t sys_rt_sigaction;

extern syscall_handler_t old_mmap_i386;

extern syscall_handler_t *sys_call_table[];

#define EXECUTE_SYSCALL(syscall, regs) \
Expand Down
2 changes: 1 addition & 1 deletion arch/um/sys-i386/sys_call_table.S
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define sys_vm86old sys_ni_syscall
#define sys_vm86 sys_ni_syscall

#define old_mmap old_mmap_i386
#define old_mmap sys_old_mmap

#define ptregs_fork sys_fork
#define ptregs_execve sys_execve
Expand Down
Loading

0 comments on commit a467937

Please sign in to comment.