diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1998-05-07 02:55:41 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1998-05-07 02:55:41 +0000 |
commit | dcec8a13bf565e47942a1751a9cec21bec5648fe (patch) | |
tree | 548b69625b18cc2e88c3e68d0923be546c9ebb03 /arch/sparc64/kernel/sys_sparc.c | |
parent | 2e0f55e79c49509b7ff70ff1a10e1e9e90a3dfd4 (diff) |
o Merge with Linux 2.1.99.
o Fix ancient bug in the ELF loader making ldd crash.
o Fix ancient bug in the keyboard code for SGI, SNI and Jazz.
Diffstat (limited to 'arch/sparc64/kernel/sys_sparc.c')
-rw-r--r-- | arch/sparc64/kernel/sys_sparc.c | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/arch/sparc64/kernel/sys_sparc.c b/arch/sparc64/kernel/sys_sparc.c index e0e69abd9..b5198074d 100644 --- a/arch/sparc64/kernel/sys_sparc.c +++ b/arch/sparc64/kernel/sys_sparc.c @@ -1,4 +1,4 @@ -/* $Id: sys_sparc.c,v 1.9 1997/12/11 15:15:44 jj Exp $ +/* $Id: sys_sparc.c,v 1.13 1998/03/29 10:10:52 davem Exp $ * linux/arch/sparc64/kernel/sys_sparc.c * * This file contains various random system calls that @@ -10,6 +10,7 @@ #include <linux/types.h> #include <linux/sched.h> #include <linux/fs.h> +#include <linux/file.h> #include <linux/mm.h> #include <linux/sem.h> #include <linux/msg.h> @@ -40,7 +41,7 @@ asmlinkage unsigned long sparc_brk(unsigned long brk) unsigned long ret; lock_kernel(); - if(brk >= 0x80000000000ULL) { /* VM hole */ + if(brk >= 0x80000000000UL) { /* VM hole */ ret = current->mm->brk; goto out; } @@ -128,6 +129,16 @@ asmlinkage int sys_ipc (unsigned call, int first, int second, unsigned long thir if (call <= SHMCTL) switch (call) { case SHMAT: + if (first >= 0) { + extern struct shmid_ds *shm_segs[]; + struct shmid_ds *shp = shm_segs[(unsigned int) first % SHMMNI]; + if (shp == IPC_UNUSED || shp == IPC_NOID) { + err = -ENOMEM; + if ((unsigned long)ptr >= 0x80000000000UL - shp->shm_segsz && + (unsigned long)ptr < 0xfffff80000000000UL) + goto out; /* Somebody is trying to fool us */ + } + } err = sys_shmat (first, (char *) ptr, second, (ulong *) third); goto out; case SHMDT: @@ -162,29 +173,39 @@ asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len, lock_kernel(); if (!(flags & MAP_ANONYMOUS)) { - if (fd >= NR_OPEN || !(file = current->files->fd[fd])){ + file = fget(fd); + if (!file) goto out; - } } retval = -ENOMEM; + len = PAGE_ALIGN(len); if(!(flags & MAP_FIXED) && !addr) { addr = get_unmapped_area(addr, len); - if(!addr){ - goto out; - } + if(!addr) + goto out_putf; } - /* See asm-sparc64/uaccess.h */ retval = -EINVAL; - if((len > (TASK_SIZE - PAGE_SIZE)) || (addr > (TASK_SIZE-len-PAGE_SIZE))) - goto out; - - if(addr >= 0x80000000000ULL) { - retval = current->mm->brk; - goto out; + if (current->tss.flags & SPARC_FLAG_32BIT) { + if (len > 0xf0000000UL || addr > 0xf0000000UL - len) + goto out_putf; + } else { + if (len >= 0x80000000000UL || + (addr < 0x80000000000UL && + addr > 0x80000000000UL-len)) + goto out_putf; + if (addr >= 0x80000000000ULL && addr < 0xfffff80000000000UL) { + /* VM hole */ + retval = current->mm->brk; + goto out_putf; + } } retval = do_mmap(file, addr, len, prot, flags, off); + +out_putf: + if (file) + fput(file); out: unlock_kernel(); return retval; |