summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsg <jsg@openbsd.org>2020-12-20 03:42:01 +0000
committerjsg <jsg@openbsd.org>2020-12-20 03:42:01 +0000
commit17bbd69690d40217bce371e25abce3920a39b686 (patch)
treea7141fbe7d1a4a4901f56c7ced9383eae0bef1b7
parentPrint client kem key with correct length. (diff)
downloadwireguard-openbsd-17bbd69690d40217bce371e25abce3920a39b686.tar.xz
wireguard-openbsd-17bbd69690d40217bce371e25abce3920a39b686.zip
test against [VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS] in access_ok()
ok kettenis@
-rw-r--r--sys/dev/pci/drm/include/linux/uaccess.h11
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)