Don't allow access to illegal addresses in /dev/kmem to panic kernel
(eg: above 0xffc00000). Programs using /dev/kmem are implicitly racing the kernel, and can get right up high in memory. I've been running these for some time now, but with printfs. It's saved two panics at least that I can remember.
This commit is contained in:
parent
1f8745a9c3
commit
d021fc112b
@ -38,7 +38,7 @@
|
||||
*
|
||||
* from: Utah $Hdr: mem.c 1.13 89/10/08$
|
||||
* from: @(#)mem.c 7.2 (Berkeley) 5/9/91
|
||||
* $Id: mem.c,v 1.42 1997/04/14 15:54:26 bde Exp $
|
||||
* $Id: mem.c,v 1.43 1997/05/07 20:02:37 peter Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -239,6 +239,11 @@ mmrw(dev, uio, flags)
|
||||
*/
|
||||
addr = trunc_page(uio->uio_offset);
|
||||
eaddr = round_page(uio->uio_offset + c);
|
||||
|
||||
if (addr < (vm_offset_t)VADDR(PTDPTDI, 0))
|
||||
return EFAULT;
|
||||
if (eaddr >= (vm_offset_t)VADDR(APTDPTDI, 0))
|
||||
return EFAULT;
|
||||
for (; addr < eaddr; addr += PAGE_SIZE)
|
||||
if (pmap_extract(kernel_pmap, addr) == 0)
|
||||
return EFAULT;
|
||||
|
@ -38,7 +38,7 @@
|
||||
*
|
||||
* from: Utah $Hdr: mem.c 1.13 89/10/08$
|
||||
* from: @(#)mem.c 7.2 (Berkeley) 5/9/91
|
||||
* $Id: mem.c,v 1.42 1997/04/14 15:54:26 bde Exp $
|
||||
* $Id: mem.c,v 1.43 1997/05/07 20:02:37 peter Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -239,6 +239,11 @@ mmrw(dev, uio, flags)
|
||||
*/
|
||||
addr = trunc_page(uio->uio_offset);
|
||||
eaddr = round_page(uio->uio_offset + c);
|
||||
|
||||
if (addr < (vm_offset_t)VADDR(PTDPTDI, 0))
|
||||
return EFAULT;
|
||||
if (eaddr >= (vm_offset_t)VADDR(APTDPTDI, 0))
|
||||
return EFAULT;
|
||||
for (; addr < eaddr; addr += PAGE_SIZE)
|
||||
if (pmap_extract(kernel_pmap, addr) == 0)
|
||||
return EFAULT;
|
||||
|
Loading…
Reference in New Issue
Block a user