Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern kobj_machdep() needs a chance to moify the loaded c...
details: https://anonhg.NetBSD.org/src/rev/f58b2e645e3e
branches: trunk
changeset: 346769:f58b2e645e3e
user: martin <martin%NetBSD.org@localhost>
date: Tue Aug 02 12:23:08 2016 +0000
description:
kobj_machdep() needs a chance to moify the loaded code, so move the code
to protect it read-only a bit later.
diffstat:
sys/kern/subr_kobj.c | 25 ++++++++++++-------------
1 files changed, 12 insertions(+), 13 deletions(-)
diffs (53 lines):
diff -r 4f8a94eba4dd -r f58b2e645e3e sys/kern/subr_kobj.c
--- a/sys/kern/subr_kobj.c Tue Aug 02 08:05:05 2016 +0000
+++ b/sys/kern/subr_kobj.c Tue Aug 02 12:23:08 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_kobj.c,v 1.58 2016/08/01 15:41:05 maxv Exp $ */
+/* $NetBSD: subr_kobj.c,v 1.59 2016/08/02 12:23:08 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.58 2016/08/01 15:41:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.59 2016/08/02 12:23:08 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_modular.h"
@@ -757,15 +757,6 @@
/* Jettison unneeded memory post-link. */
kobj_jettison(ko);
- /* Change the memory protections, when needed. */
- uvm_km_protect(module_map, ko->ko_text_address, ko->ko_text_size,
- VM_PROT_READ|VM_PROT_EXECUTE);
- if (ko->ko_rodata_address != 0) {
- uvm_km_protect(module_map, ko->ko_rodata_address,
- ko->ko_rodata_size, VM_PROT_READ);
- }
-
-
/*
* Notify MD code that a module has been loaded.
*
@@ -797,8 +788,16 @@
ko->ko_loaded = true;
}
- /* If there was an error, destroy the whole object. */
- if (error != 0) {
+ if (error == 0) {
+ /* Change the memory protections, when needed. */
+ uvm_km_protect(module_map, ko->ko_text_address,
+ ko->ko_text_size, VM_PROT_READ|VM_PROT_EXECUTE);
+ if (ko->ko_rodata_address != 0) {
+ uvm_km_protect(module_map, ko->ko_rodata_address,
+ ko->ko_rodata_size, VM_PROT_READ);
+ }
+ } else {
+ /* If there was an error, destroy the whole object. */
kobj_unload(ko);
}
Home |
Main Index |
Thread Index |
Old Index