Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/netbsd32 If a syscall requires a module to be aut...



details:   https://anonhg.NetBSD.org/src/rev/70d11d2f2633
branches:  trunk
changeset: 745693:70d11d2f2633
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Mon Mar 09 01:06:34 2020 +0000

description:
If a syscall requires a module to be autoloaded, the initial invocation
of that syscall will return ERESTART.  For amd64's netbsd32_syscall()
that means we need to back up the PC saved in the trap frame so we can
re-issue the syscall instruction.  For "normal" syscall traps, we saved
the instruction length in the trap frame, but this was missing for the
oosyscall/lcall path.  Since the PC was not backed up, the kernel-only
value ERESTART was returned to userland, causing all sort of grief for
old compat_netbsd32 executables!

XXX Pullup-9

diffstat:

 sys/compat/netbsd32/netbsd32_mod.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (64 lines):

diff -r d27a5edaa732 -r 70d11d2f2633 sys/compat/netbsd32/netbsd32_mod.c
--- a/sys/compat/netbsd32/netbsd32_mod.c        Mon Mar 09 00:42:36 2020 +0000
+++ b/sys/compat/netbsd32/netbsd32_mod.c        Mon Mar 09 01:06:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_mod.c,v 1.18 2020/03/08 04:17:49 pgoyette Exp $       */
+/*     $NetBSD: netbsd32_mod.c,v 1.19 2020/03/09 01:06:34 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.18 2020/03/08 04:17:49 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.19 2020/03/09 01:06:34 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -148,8 +148,9 @@
            copyin((void *)frame->tf_rip, tmp, sz) == 0 &&
            memcmp(tmp, lcall, sz) == 0) {
 
-               /* Advance past the lcall. */
+               /* 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);
@@ -157,7 +158,7 @@
        } else
                return EPASSTHROUGH;
 }
-#endif
+#endif /* defined(__amd64__) */
 
 static int
 compat_netbsd32_modcmd(modcmd_t cmd, void *arg)
@@ -175,14 +176,14 @@
 #if defined(__amd64__)
                        MODULE_HOOK_SET(amd64_oosyscall_hook,
                            amd64_oosyscall_handle);
-#endif
+#endif /* defined(__amd64__) */
                }
                return error;
 
        case MODULE_CMD_FINI:
 #if defined(__amd64__)
                MODULE_HOOK_UNSET(amd64_oosyscall_hook);
-#endif
+#endif /* defined(__amd64__) */
                netbsd32_machdep_md_fini();
                netbsd32_sysctl_fini();
                netbsd32_kern_proc_32_fini();
@@ -196,7 +197,7 @@
 #if defined(__amd64__)
                        MODULE_HOOK_SET(amd64_oosyscall_hook,
                            amd64_oosyscall_handle);
-#endif
+#endif /* defined(__amd64__) */
                }
                return error;
 



Home | Main Index | Thread Index | Old Index