diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-12-20 03:42:02 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-12-20 03:42:02 +0000 |
commit | b0cd514bd17fc3ef784581ccf88e51a42e3559b8 (patch) | |
tree | 09334fe321afd890dd9a08aa951109bb123ac258 /sys/dev/pci/drm | |
parent | 575d91082668da6066a21ef050b6189ef3425641 (diff) |
test against [VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS] in access_ok()
ok kettenis@
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r-- | sys/dev/pci/drm/include/linux/uaccess.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/dev/pci/drm/include/linux/uaccess.h b/sys/dev/pci/drm/include/linux/uaccess.h index 765a0546caf..99ef746cc4a 100644 --- a/sys/dev/pci/drm/include/linux/uaccess.h +++ b/sys/dev/pci/drm/include/linux/uaccess.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uaccess.h,v 1.4 2020/11/17 11:20:59 jsg Exp $ */ +/* $OpenBSD: uaccess.h,v 1.5 2020/12/20 03:42:01 jsg Exp $ */ /* * Copyright (c) 2015 Mark Kettenis * @@ -18,8 +18,10 @@ #ifndef _LINUX_UACCESS_H #define _LINUX_UACCESS_H -#include <sys/types.h> +#include <sys/param.h> #include <sys/systm.h> +#include <uvm/uvm_extern.h> + #include <linux/sched.h> static inline unsigned long @@ -67,7 +69,10 @@ copy_from_user(void *to, const void *from, unsigned len) static inline int access_ok(const void *addr, unsigned long size) { - return 1; + vaddr_t startva = (vaddr_t)addr; + vaddr_t endva = ((vaddr_t)addr) + size; + return (startva >= VM_MIN_ADDRESS && endva >= VM_MIN_ADDRESS) && + (startva <= VM_MAXUSER_ADDRESS && endva <= VM_MAXUSER_ADDRESS); } #define user_access_begin(addr, size) access_ok(addr, size) |