Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern only do the temporary symbol table load #ifdef DDB ...



details:   https://anonhg.NetBSD.org/src/rev/79e6811430f8
branches:  trunk
changeset: 572344:79e6811430f8
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Thu Dec 30 11:47:02 2004 +0000

description:
only do the temporary symbol table load #ifdef DDB and add comment for
the code block, so that the purpose is more clear

avoid NULL pointer dereference in lkmunreserve() called on lkm device
close when ksym_addsymtab() fails for the temporary symbol table
(sanity change only, this can never happen at the moment)

diffstat:

 sys/kern/kern_lkm.c |  18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diffs (65 lines):

diff -r e57235e9d824 -r 79e6811430f8 sys/kern/kern_lkm.c
--- a/sys/kern/kern_lkm.c       Thu Dec 30 11:35:41 2004 +0000
+++ b/sys/kern/kern_lkm.c       Thu Dec 30 11:47:02 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_lkm.c,v 1.79 2004/12/30 11:35:41 jdolecek Exp $   */
+/*     $NetBSD: kern_lkm.c,v 1.80 2004/12/30 11:47:02 jdolecek Exp $   */
 
 /*
  * Copyright (c) 1994 Christopher G. Demetriou
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.79 2004/12/30 11:35:41 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.80 2004/12/30 11:47:02 jdolecek Exp $");
 
 #include "opt_ddb.h"
 #include "opt_malloclog.h"
@@ -483,18 +483,27 @@
                               curp->size - curp->offset);
                }
 
+#ifdef DDB
+               /*
+                * Temporarily load the symbol table before the entry
+                * routine is called, so that the symbols are available
+                * for DDB backtrace and breakpoints.
+                */
                if (curp->syms && curp->sym_offset >= curp->sym_size) {
                        error = ksyms_addsymtab("/lkmtemp/",
                            (char *)curp->syms, curp->sym_symsize,
                            (char *)curp->syms + curp->sym_symsize,
                            curp->sym_size - curp->sym_symsize);
+
                        if (error)
-                               break;
+                               goto rdyfail;
+
 #ifdef DEBUG
                        if (lkmdebug & LKMDB_INFO)
                                printf( "DDB symbols added!\n" );
 #endif
                }
+#endif /* DDB */
 
                curp->entry = (int (*)(struct lkm_table *, int, int))
                                (*((long *) (data)));
@@ -503,7 +512,9 @@
                error = (*(curp->entry))(curp, LKM_E_LOAD, LKM_VERSION);
 
                if (curp->syms && curp->sym_offset >= curp->sym_size) {
+#ifdef DDB
                        ksyms_delsymtab("/lkmtemp/");
+#endif
 
                        if (!error) {
                                error = ksyms_addsymtab(curp->private.lkm_any->lkm_name,
@@ -514,6 +525,7 @@
                }
 
                if (error) {
+    rdyfail:
                        /*
                         * Module may refuse loading or may have a
                         * version mismatch...



Home | Main Index | Thread Index | Old Index