[PATCH] IA64,sparc: local DoS with corrupted ELFs
This prevents cross-region mappings on IA64 and SPARC which could lead to system crash. They were correctly trapped for normal mmap() calls, but not for the kernel internal calls generated by executable loading. This code just moves the architecture-specific cross-region checks into an arch-specific "arch_mmap_check()" macro, and defines that for the architectures that needed it (ia64, sparc and sparc64). Architectures that don't have any special requirements can just ignore the new cross-region check, since the mmap() code will just notice on its own when the macro isn't defined. Signed-off-by: Pavel Emelianov <xemul@openvz.org> Signed-off-by: Kirill Korotaev <dev@openvz.org> Acked-by: David Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> [ Cleaned up to not affect architectures that don't need it ] Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
committed by
Linus Torvalds
parent
10387e5eb4
commit
3a45975681
@@ -163,10 +163,25 @@ sys_pipe (void)
|
||||
return retval;
|
||||
}
|
||||
|
||||
int ia64_mmap_check(unsigned long addr, unsigned long len,
|
||||
unsigned long flags)
|
||||
{
|
||||
unsigned long roff;
|
||||
|
||||
/*
|
||||
* Don't permit mappings into unmapped space, the virtual page table
|
||||
* of a region, or across a region boundary. Note: RGN_MAP_LIMIT is
|
||||
* equal to 2^n-PAGE_SIZE (for some integer n <= 61) and len > 0.
|
||||
*/
|
||||
roff = REGION_OFFSET(addr);
|
||||
if ((len > RGN_MAP_LIMIT) || (roff > (RGN_MAP_LIMIT - len)))
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
do_mmap2 (unsigned long addr, unsigned long len, int prot, int flags, int fd, unsigned long pgoff)
|
||||
{
|
||||
unsigned long roff;
|
||||
struct file *file = NULL;
|
||||
|
||||
flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
|
||||
@@ -188,17 +203,6 @@ do_mmap2 (unsigned long addr, unsigned long len, int prot, int flags, int fd, un
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't permit mappings into unmapped space, the virtual page table of a region,
|
||||
* or across a region boundary. Note: RGN_MAP_LIMIT is equal to 2^n-PAGE_SIZE
|
||||
* (for some integer n <= 61) and len > 0.
|
||||
*/
|
||||
roff = REGION_OFFSET(addr);
|
||||
if ((len > RGN_MAP_LIMIT) || (roff > (RGN_MAP_LIMIT - len))) {
|
||||
addr = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
down_write(¤t->mm->mmap_sem);
|
||||
addr = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
|
||||
up_write(¤t->mm->mmap_sem);
|
||||
|
Reference in New Issue
Block a user