summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1997-11-20 18:09:36 +0000
committerbde <bde@FreeBSD.org>1997-11-20 18:09:36 +0000
commitdfbf1ec5a96e49d821416565e5196af4a3be0882 (patch)
treeedf0fecf43dc743e48e4835f8ebd2e8c50a25ccc /sys
parentdbdea37b8422a75dd03baeb05d688bb75fceff8e (diff)
downloadFreeBSD-src-dfbf1ec5a96e49d821416565e5196af4a3be0882.zip
FreeBSD-src-dfbf1ec5a96e49d821416565e5196af4a3be0882.tar.gz
Fixed write enabling of the kernel text section. The overlap
checking was mostly wrong at the boundaries. For the lower limit, VM_MIN_KERNEL_ADDRESS was used instead of btext and there was an off-by-(`size' - 1) error. For the upper limit, &etext was used instead of etext and there was an off-by-1 error. The bugs were harmless because `size' is not too large and some memory is mapped just beyond the ends. We still depend on the former to avoid having to handle the case where the memory range covers the whole text section, and on the latter to prevent problems when we map just beyond an end to allow writing an address range that overlaps the end. Fixed placement of a nearby comment.
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/db_interface.c12
-rw-r--r--sys/i386/i386/db_interface.c12
2 files changed, 10 insertions, 14 deletions
diff --git a/sys/amd64/amd64/db_interface.c b/sys/amd64/amd64/db_interface.c
index b05285a..513c97e 100644
--- a/sys/amd64/amd64/db_interface.c
+++ b/sys/amd64/amd64/db_interface.c
@@ -23,7 +23,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: db_interface.c,v 1.36 1997/08/07 05:15:46 dyson Exp $
+ * $Id: db_interface.c,v 1.37 1997/10/27 17:23:12 bde Exp $
*/
/*
@@ -41,7 +41,6 @@
#endif
#include <vm/vm.h>
-#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <ddb/ddb.h>
@@ -247,17 +246,16 @@ db_write_bytes(addr, size, data)
db_nofault = &db_jmpbuf;
- if (addr >= VM_MIN_KERNEL_ADDRESS &&
- addr <= round_page((vm_offset_t)&etext)) {
+ if (addr > trunc_page((vm_offset_t)btext) - size &&
+ addr < round_page((vm_offset_t)etext)) {
ptep0 = pmap_pte(kernel_pmap, addr);
oldmap0 = *ptep0;
*ptep0 |= PG_RW;
- if ((*ptep0 & PG_PS) == 0) {
+ /* Map another page if the data crosses a page boundary. */
+ if ((*ptep0 & PG_PS) == 0) {
addr1 = trunc_page(addr + size - 1);
-
- /* Map another page if the data crosses a page boundary. */
if (trunc_page(addr) != addr1) {
ptep1 = pmap_pte(kernel_pmap, addr1);
oldmap1 = *ptep1;
diff --git a/sys/i386/i386/db_interface.c b/sys/i386/i386/db_interface.c
index b05285a..513c97e 100644
--- a/sys/i386/i386/db_interface.c
+++ b/sys/i386/i386/db_interface.c
@@ -23,7 +23,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: db_interface.c,v 1.36 1997/08/07 05:15:46 dyson Exp $
+ * $Id: db_interface.c,v 1.37 1997/10/27 17:23:12 bde Exp $
*/
/*
@@ -41,7 +41,6 @@
#endif
#include <vm/vm.h>
-#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <ddb/ddb.h>
@@ -247,17 +246,16 @@ db_write_bytes(addr, size, data)
db_nofault = &db_jmpbuf;
- if (addr >= VM_MIN_KERNEL_ADDRESS &&
- addr <= round_page((vm_offset_t)&etext)) {
+ if (addr > trunc_page((vm_offset_t)btext) - size &&
+ addr < round_page((vm_offset_t)etext)) {
ptep0 = pmap_pte(kernel_pmap, addr);
oldmap0 = *ptep0;
*ptep0 |= PG_RW;
- if ((*ptep0 & PG_PS) == 0) {
+ /* Map another page if the data crosses a page boundary. */
+ if ((*ptep0 & PG_PS) == 0) {
addr1 = trunc_page(addr + size - 1);
-
- /* Map another page if the data crosses a page boundary. */
if (trunc_page(addr) != addr1) {
ptep1 = pmap_pte(kernel_pmap, addr1);
oldmap1 = *ptep1;
OpenPOWER on IntegriCloud