Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/pgoyette-compat]: src/sys More work on kern_proc_32
details: https://anonhg.NetBSD.org/src/rev/837f8c251cdb
branches: pgoyette-compat
changeset: 830767:837f8c251cdb
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sun Sep 23 11:23:47 2018 +0000
description:
More work on kern_proc_32
diffstat:
sys/compat/netbsd32/files.netbsd32 | 3 +-
sys/compat/netbsd32/netbsd32.h | 9 +-
sys/compat/netbsd32/netbsd32_kern_proc.c | 158 +++++++++++++++++++++++++++++++
sys/compat/netbsd32/netbsd32_kern_proc.h | 38 +++++++
sys/compat/netbsd32/netbsd32_mod.c | 9 +-
sys/kern/kern_proc.c | 55 ++++------
sys/sys/compat_stub.h | 10 +-
7 files changed, 243 insertions(+), 39 deletions(-)
diffs (truncated from 430 to 300 lines):
diff -r 4267087639cd -r 837f8c251cdb sys/compat/netbsd32/files.netbsd32
--- a/sys/compat/netbsd32/files.netbsd32 Sun Sep 23 10:41:01 2018 +0000
+++ b/sys/compat/netbsd32/files.netbsd32 Sun Sep 23 11:23:47 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.netbsd32,v 1.39.14.4 2018/09/12 04:35:22 pgoyette Exp $
+# $NetBSD: files.netbsd32,v 1.39.14.5 2018/09/23 11:23:47 pgoyette Exp $
#
# config file description for machine-independent netbsd32 compat code.
# included by ports that need it.
@@ -14,6 +14,7 @@
file compat/netbsd32/netbsd32_event.c compat_netbsd32
file compat/netbsd32/netbsd32_execve.c compat_netbsd32
file compat/netbsd32/netbsd32_fs.c compat_netbsd32
+file compat/netbsd32/netbsd32_kern_proc.c compat_netbsd32
file compat/netbsd32/netbsd32_ioctl.c compat_netbsd32
file compat/netbsd32/netbsd32_ipc.c compat_netbsd32
file compat/netbsd32/netbsd32_lwp.c compat_netbsd32
diff -r 4267087639cd -r 837f8c251cdb sys/compat/netbsd32/netbsd32.h
--- a/sys/compat/netbsd32/netbsd32.h Sun Sep 23 10:41:01 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32.h Sun Sep 23 11:23:47 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32.h,v 1.116.2.10 2018/09/23 09:16:49 pgoyette Exp $ */
+/* $NetBSD: netbsd32.h,v 1.116.2.11 2018/09/23 11:23:47 pgoyette Exp $ */
/*
* Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
@@ -1181,6 +1181,13 @@
MODULE_HOOK(compat32_80_modctl_hook,
(struct lwp *, const struct netbsd32_modctl_args *, register_t *));
+/*
+ * kern_proc compatability for netbsd32
+ */
+struct ps_strings;
+MODULE_HOOK2(kern_proc_32_hook, (struct proc *, struct ps_strings *),
+ (char **, size_t, vaddr_t *));
+
/*
* Finally, declare emul_netbsd32 as this is needed in lots of
* places when calling syscall_{,dis}establish()
diff -r 4267087639cd -r 837f8c251cdb sys/compat/netbsd32/netbsd32_kern_proc.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/netbsd32/netbsd32_kern_proc.c Sun Sep 23 11:23:47 2018 +0000
@@ -0,0 +1,158 @@
+/* $NetBSD: netbsd32_kern_proc.c,v 1.1.2.1 2018/09/23 11:23:47 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center, and by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)kern_proc.c 8.7 (Berkeley) 2/14/95
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_kern_proc.c,v 1.1.2.1 2018/09/23 11:23:47 pgoyette Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_kstack.h"
+#include "opt_maxuprc.h"
+#include "opt_dtrace.h"
+#include "opt_compat_netbsd32.h"
+#endif
+
+#if defined(__HAVE_COMPAT_NETBSD32) && !defined(COMPAT_NETBSD32) \
+ && !defined(_RUMPKERNEL)
+#define COMPAT_NETBSD32
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/resourcevar.h>
+#include <sys/buf.h>
+#include <sys/acct.h>
+#include <sys/wait.h>
+#include <sys/file.h>
+#include <ufs/ufs/quota.h>
+#include <sys/uio.h>
+#include <sys/pool.h>
+#include <sys/pset.h>
+#include <sys/mbuf.h>
+#include <sys/ioctl.h>
+#include <sys/tty.h>
+#include <sys/signalvar.h>
+#include <sys/ras.h>
+#include <sys/filedesc.h>
+#include <sys/syscall_stats.h>
+#include <sys/kauth.h>
+#include <sys/sleepq.h>
+#include <sys/atomic.h>
+#include <sys/kmem.h>
+#include <sys/namei.h>
+#include <sys/dtrace_bsd.h>
+#include <sys/sysctl.h>
+#include <sys/exec.h>
+#include <sys/cpu.h>
+
+#include <uvm/uvm_extern.h>
+#include <uvm/uvm.h>
+
+#include <compat/netbsd32/netbsd32.h>
+
+static int
+copyin_psstrings_32(struct proc *p, struct ps_strings *arginfo)
+{
+ struct ps_strings32 arginfo32;
+
+ int error = copyin_proc(p, (void *)p->p_psstrp, &arginfo32,
+ sizeof(arginfo32));
+ if (error)
+ return error;
+ arginfo->ps_argvstr = (void *)(uintptr_t)arginfo32.ps_argvstr;
+ arginfo->ps_nargvstr = arginfo32.ps_nargvstr;
+ arginfo->ps_envstr = (void *)(uintptr_t)arginfo32.ps_envstr;
+ arginfo->ps_nenvstr = arginfo32.ps_nenvstr;
+ return 0;
+}
+
+static int
+get_base32(char **argv, size_t i, vaddr_t *base)
+{
+
+ netbsd32_charp *argv32;
+
+ argv32 = (netbsd32_charp *)argv;
+ *base = (vaddr_t)NETBSD32PTR64(argv32[i]);
+
+ return 0;
+}
+
+MODULE_SET_HOOK2(kern_proc_32_hook, "kern_proc_32",
+ copyin_psstrings_32, get_base32);
+MODULE_UNSET_HOOK2(kern_proc_32_hook);
+
+void
+kern_proc_32_init(void)
+{
+
+ kern_proc_32_hook_set();
+}
+
+void
+kern_proc_32_fini(void)
+{
+
+ kern_proc_32_hook_unset();
+}
diff -r 4267087639cd -r 837f8c251cdb sys/compat/netbsd32/netbsd32_kern_proc.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/netbsd32/netbsd32_kern_proc.h Sun Sep 23 11:23:47 2018 +0000
@@ -0,0 +1,38 @@
+/* $NetBSD: netbsd32_kern_proc.h,v 1.1.2.1 2018/09/23 11:23:47 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _NETBSD32_KERN_PROC_H
+#define _NETBSD32_KERN_PROC_H
+
+void netbsd32_kern_proc_32_init(void);
+void netbsd32_kern_proc_32_fini(void);
+
+#endif /* !_NETBSD32_KERN_PROC_H */
diff -r 4267087639cd -r 837f8c251cdb sys/compat/netbsd32/netbsd32_mod.c
--- a/sys/compat/netbsd32/netbsd32_mod.c Sun Sep 23 10:41:01 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_mod.c Sun Sep 23 11:23:47 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_mod.c,v 1.13.16.13 2018/09/18 23:03:54 pgoyette Exp $ */
+/* $NetBSD: netbsd32_mod.c,v 1.13.16.14 2018/09/23 11:23:47 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.13.16.13 2018/09/18 23:03:54 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.13.16.14 2018/09/23 11:23:47 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_execfmt.h"
@@ -47,12 +47,14 @@
#include <sys/module_hook.h>
#include <compat/netbsd32/netbsd32_sysctl.h>
+#include <compat/netbsd32/netbsd32_kern_proc.h>
#include <compat/netbsd32/netbsd32_exec.h>
#define ELF32_AUXSIZE (howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), \
sizeof(Elf32_Addr)) + MAXPATHLEN + ALIGN(1))
struct compat32_80_modctl_hook_t compat32_80_modctl_hook;
+struct kern_proc_32_hook_t kern_proc_32_hook;
# define DEPS1 "ksem,coredump,compat_util"
@@ -111,16 +113,19 @@
if (error == 0) {
netbsd32_sysctl_init();
netbsd32_machdep_md_init();
+ kern_proc_32_init();
}
return error;
case MODULE_CMD_FINI:
netbsd32_machdep_md_fini();
netbsd32_sysctl_fini();
+ kern_proc_32_fini();
error = exec_remove(netbsd32_execsw,
__arraycount(netbsd32_execsw));
if (error) {
+ kern_proc_32_init();
netbsd32_sysctl_init();
netbsd32_machdep_md_init();
}
diff -r 4267087639cd -r 837f8c251cdb sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c Sun Sep 23 10:41:01 2018 +0000
+++ b/sys/kern/kern_proc.c Sun Sep 23 11:23:47 2018 +0000
Home |
Main Index |
Thread Index |
Old Index