Guard against address wrap in kernacc(). Otherwise, a program accessing a

bad address range through /dev/kmem can panic the machine.

Submitted by: Mark W. Krentel
Reported by: Kris Kennaway
MFC after: 1 week
This commit is contained in:
Alan Cox 2005-01-22 19:21:29 +00:00
parent 14cedfc842
commit 75337a5677
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=140622

View File

@ -133,6 +133,11 @@ kernacc(addr, len, rw)
KASSERT((rw & ~VM_PROT_ALL) == 0,
("illegal ``rw'' argument to kernacc (%x)\n", rw));
if ((vm_offset_t)addr + len > kernel_map->max_offset ||
(vm_offset_t)addr + len < (vm_offset_t)addr)
return (FALSE);
prot = rw;
saddr = trunc_page((vm_offset_t)addr);
eaddr = round_page((vm_offset_t)addr + len);