Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm Don't silently truncate the voff_t offset to vaddr_t...
details: https://anonhg.NetBSD.org/src/rev/79eb7d3afe37
branches: trunk
changeset: 486765:79eb7d3afe37
user: drochner <drochner%NetBSD.org@localhost>
date: Sun May 28 10:21:55 2000 +0000
description:
Don't silently truncate the voff_t offset to vaddr_t when passing it to
udv_attach. Pass the whole voff_t instead and do an explicite overflow
check before it is passed to the device's mmap handler (as "int", sadly).
diffstat:
sys/uvm/uvm_device.c | 13 +++++++++++--
sys/uvm/uvm_device.h | 4 ++--
2 files changed, 13 insertions(+), 4 deletions(-)
diffs (52 lines):
diff -r d8001087fab3 -r 79eb7d3afe37 sys/uvm/uvm_device.c
--- a/sys/uvm/uvm_device.c Sun May 28 09:59:48 2000 +0000
+++ b/sys/uvm/uvm_device.c Sun May 28 10:21:55 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_device.c,v 1.21 2000/04/03 07:35:24 chs Exp $ */
+/* $NetBSD: uvm_device.c,v 1.22 2000/05/28 10:21:55 drochner Exp $ */
/*
*
@@ -131,7 +131,7 @@
udv_attach(arg, accessprot, off, size)
void *arg;
vm_prot_t accessprot;
- vaddr_t off; /* used only for access check */
+ voff_t off; /* used only for access check */
vsize_t size; /* used only for access check */
{
dev_t device = *((dev_t *) arg);
@@ -152,6 +152,15 @@
return(NULL);
/*
+ * As long as the device d_mmap interface gets an "int"
+ * offset, we have to watch out not to overflow its
+ * numeric range. (assuming it will be interpreted as
+ * "unsigned")
+ */
+ if (((off + size - 1) & (u_int)-1) != off + size - 1)
+ return (0);
+
+ /*
* Check that the specified range of the device allows the
* desired protection.
*
diff -r d8001087fab3 -r 79eb7d3afe37 sys/uvm/uvm_device.h
--- a/sys/uvm/uvm_device.h Sun May 28 09:59:48 2000 +0000
+++ b/sys/uvm/uvm_device.h Sun May 28 10:21:55 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_device.h,v 1.8 1999/06/21 17:25:11 thorpej Exp $ */
+/* $NetBSD: uvm_device.h,v 1.9 2000/05/28 10:21:55 drochner Exp $ */
/*
*
@@ -69,7 +69,7 @@
* prototypes
*/
-struct uvm_object *udv_attach __P((void *, vm_prot_t, vaddr_t, vsize_t));
+struct uvm_object *udv_attach __P((void *, vm_prot_t, voff_t, vsize_t));
#endif /* _KERNEL */
Home |
Main Index |
Thread Index |
Old Index