Source-Changes-HG archive

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

[src/trunk]: src/sys Rework previous, so that the real syscall code is not in...



details:   https://anonhg.NetBSD.org/src/rev/98706ea605e0
branches:  trunk
changeset: 745734:98706ea605e0
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Mon Mar 09 21:49:26 2020 +0000

description:
Rework previous, so that the real syscall code is not invoked from within
the module_hook code.  Otherwise, if the syscall just happens to be exit()
we will exit while still holding a reference to the hook's localcount, and
nothing will ever release that reference.  Attempts to manually unload the
module will hang indefinitely, as will modstat(8).

XXX pullup-9

diffstat:

 sys/arch/amd64/amd64/trap.c        |  9 ++++++---
 sys/compat/netbsd32/netbsd32_mod.c |  7 ++-----
 2 files changed, 8 insertions(+), 8 deletions(-)

diffs (59 lines):

diff -r 5171147c8cee -r 98706ea605e0 sys/arch/amd64/amd64/trap.c
--- a/sys/arch/amd64/amd64/trap.c       Mon Mar 09 21:20:55 2020 +0000
+++ b/sys/arch/amd64/amd64/trap.c       Mon Mar 09 21:49:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.126 2020/03/08 00:53:12 pgoyette Exp $      */
+/*     $NetBSD: trap.c,v 1.127 2020/03/09 21:49:26 pgoyette Exp $      */
 
 /*
  * Copyright (c) 1998, 2000, 2017 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.126 2020/03/08 00:53:12 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.127 2020/03/09 21:49:26 pgoyette Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -348,8 +348,11 @@
 
                MODULE_HOOK_CALL(amd64_oosyscall_hook, (p, frame),
                        ENOSYS, hook_ret);
-               if (hook_ret == 0)
+               if (hook_ret == 0) {
+                       /* Do the syscall */
+                       p->p_md.md_syscall(frame);
                        goto out;
+               }
        }
                /* FALLTHROUGH */
        case T_TSSFLT|T_USER:
diff -r 5171147c8cee -r 98706ea605e0 sys/compat/netbsd32/netbsd32_mod.c
--- a/sys/compat/netbsd32/netbsd32_mod.c        Mon Mar 09 21:20:55 2020 +0000
+++ b/sys/compat/netbsd32/netbsd32_mod.c        Mon Mar 09 21:49:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_mod.c,v 1.19 2020/03/09 01:06:34 pgoyette Exp $       */
+/*     $NetBSD: netbsd32_mod.c,v 1.20 2020/03/09 21:49:26 pgoyette Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.19 2020/03/09 01:06:34 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.20 2020/03/09 21:49:26 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -151,9 +151,6 @@
                /* Advance past the lcall and save instruction size. */
                frame->tf_rip += sz;
                frame->tf_err = sz;
-
-               /* Do the syscall */
-               p->p_md.md_syscall(frame);
                return 0;
        } else
                return EPASSTHROUGH;



Home | Main Index | Thread Index | Old Index