From dfbf1ec5a96e49d821416565e5196af4a3be0882 Mon Sep 17 00:00:00 2001 From: bde Date: Thu, 20 Nov 1997 18:09:36 +0000 Subject: 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. --- sys/amd64/amd64/db_interface.c | 12 +++++------- sys/i386/i386/db_interface.c | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'sys') 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 -#include #include #include @@ -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 -#include #include #include @@ -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; -- cgit v1.1