Date: Tue, 12 Aug 2014 23:22:39 GMT From: op@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r272311 - soc2014/op/freebsd-base/sys/kern Message-ID: <201408122322.s7CNMdXF015160@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: op Date: Tue Aug 12 23:22:38 2014 New Revision: 272311 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=272311 Log: KSP: added KSP_WxorX_KERNEL guard, and added more code to KSP_WxorX_KERNEL case Signed-off-by: Oliver Pinter <oliver.pntr@gmail.com> git: https://github.com/opntr/opBSD/tree/op/gsoc2014/smap+kpatch Modified: soc2014/op/freebsd-base/sys/kern/kern_selfpatch.c Modified: soc2014/op/freebsd-base/sys/kern/kern_selfpatch.c ============================================================================== --- soc2014/op/freebsd-base/sys/kern/kern_selfpatch.c Tue Aug 12 23:03:11 2014 (r272310) +++ soc2014/op/freebsd-base/sys/kern/kern_selfpatch.c Tue Aug 12 23:22:38 2014 (r272311) @@ -26,7 +26,7 @@ * $FreeBSD$ */ -//#include "opt_selfpatch.h" +#include "opt_selfpatch.h" #include <sys/cdefs.h> @@ -54,6 +54,10 @@ printf(__VA_ARGS__); \ } +#ifdef KSP_WxorX_KERNEL +#undef KSP_WxorX_KERNEL +#endif /* KSP_WxorX_KERNEL */ + extern struct lf_selfpatch __start_set_selfpatch_set[]; extern struct lf_selfpatch __stop_set_selfpatch_set[]; @@ -205,7 +209,14 @@ * dummy function, currently unused becasue the kernel * protection is RWX */ -#if 0 +#ifdef KSP_WxorX_KERNEL + vm_offset_t eva, sva; + + eva = (vm_offset_t)(p->patchable); + sva = (vm_offset_t)(p->patchable + p->patchable_size); + + DBG("kernel: %p - %p RX -> RWX" + (void *)sva, (void *)eva); pmap_protect(kernel_pmap, sva, eva, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE); #endif @@ -220,7 +231,14 @@ * * currently flushes the cache after modification */ -#if 0 +#ifdef KSP_WxorX_KERNEL + vm_offset_t eva, sva; + + eva = (vm_offset_t)(p->patchable); + sva = (vm_offset_t)(p->patchable + p->patchable_size); + DBG("kernel: %p - %p RWX -> RX", + (void *)sva, (void *)eva); + pmap_protect(kernel_pmap, sva, eva, VM_PROT_READ | VM_PROT_EXECUTE); #endif @@ -228,6 +246,8 @@ /* Flushes caches and TLBs. */ wbinvd(); invltlb(); + + DBG("caches flushed."); } static void @@ -237,7 +257,14 @@ * dummy function, currently unused becasue the kernel * protection is RWX */ -#if 0 +#ifdef KSP_WxorX_KERNEL + vm_offset_t eva, sva; + + eva = (vm_offset_t)(p->patchable); + sva = (vm_offset_t)(p->patchable + p->patchable_size); + DBG("module: %p - %p RX -> RWX", + (void *)sva, (void *)eva); + pmap_protect(module_pmap, sva, eva, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE); #endif @@ -252,7 +279,14 @@ * * currently flushes the cache after modification */ -#if 0 +#ifdef KSP_WxorX_KERNEL + vm_offset_t eva, sva; + + eva = (vm_offset_t)(p->patchable); + sva = (vm_offset_t)(p->patchable + p->patchable_size); + DBG("module: %p - %p RWX -> RX", + (void *)sva, (void *)eva); + pmap_protect(module_pmap, sva, eva, VM_PROT_READ | VM_PROT_EXECUTE); #endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408122322.s7CNMdXF015160>