[PowerPC] Fix radix crash when passing -1 from userspace

Found by running libc tests with radix enabled.

Detect unsigned integer wrapping with a postcondition.

Note: Radix MMU is not enabled by default yet.

Sponsored by:	Tag1 Consulting, Inc.
This commit is contained in:
Brandon Bergren 2020-05-28 00:49:02 +00:00
parent 469f2e9e9a
commit 9b51a10a9c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=361568

View File

@ -6000,7 +6000,8 @@ mmu_radix_kremove(vm_offset_t va)
int mmu_radix_map_user_ptr(pmap_t pm,
volatile const void *uaddr, void **kaddr, size_t ulen, size_t *klen)
{
if ((uintptr_t)uaddr + ulen >= VM_MAXUSER_ADDRESS)
if ((uintptr_t)uaddr + ulen >= VM_MAXUSER_ADDRESS ||
(uintptr_t)uaddr + ulen < (uintptr_t)uaddr)
return (EFAULT);
*kaddr = (void *)(uintptr_t)uaddr;