Source-Changes-HG archive

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

[src/netbsd-1-4]: src/sys/kern Pull up revision 1.53 (requested by fvdl):



details:   https://anonhg.NetBSD.org/src/rev/c621940c58c2
branches:  netbsd-1-4
changeset: 470243:c621940c58c2
user:      he <he%NetBSD.org@localhost>
date:      Tue Feb 01 22:54:45 2000 +0000

description:
Pull up revision 1.53 (requested by fvdl):
  Close procfs security hole.  Fixes SA#2000-001.

diffstat:

 sys/kern/kern_subr.c |  68 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 67 insertions(+), 1 deletions(-)

diffs (82 lines):

diff -r 6aff801f4ce8 -r c621940c58c2 sys/kern/kern_subr.c
--- a/sys/kern/kern_subr.c      Mon Jan 31 22:39:37 2000 +0000
+++ b/sys/kern/kern_subr.c      Tue Feb 01 22:54:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_subr.c,v 1.45 1999/03/24 05:51:25 mrg Exp $       */
+/*     $NetBSD: kern_subr.c,v 1.45.2.1 2000/02/01 22:54:45 he Exp $    */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -392,6 +392,72 @@
 }
 
 /*
+ * Exec hook code.
+ */
+
+struct exechook_desc {
+       LIST_ENTRY(exechook_desc) ehk_list;
+       void    (*ehk_fn) __P((struct proc *, void *));
+       void    *ehk_arg;
+};
+
+LIST_HEAD(, exechook_desc) exechook_list;
+
+void *
+exechook_establish(fn, arg)
+       void (*fn) __P((struct proc *, void *));
+       void *arg;
+{
+       struct exechook_desc *edp;
+
+       edp = (struct exechook_desc *)
+           malloc(sizeof(*edp), M_DEVBUF, M_NOWAIT);
+       if (edp == NULL)
+               return NULL;
+
+       edp->ehk_fn = fn;
+       edp->ehk_arg = arg;
+       LIST_INSERT_HEAD(&exechook_list, edp, ehk_list);
+
+       return (edp);
+}
+
+void
+exechook_disestablish(vhook)
+       void *vhook;
+{
+#ifdef DIAGNOSTIC
+       struct exechook_desc *edp;
+
+       for (edp = exechook_list.lh_first; edp != NULL;
+           edp = edp->ehk_list.le_next)
+                if (edp == vhook)
+                       break;
+       if (edp == NULL)
+               panic("exechook_disestablish: hook not established");
+#endif
+
+       LIST_REMOVE((struct exechook_desc *)vhook, ehk_list);
+       free(vhook, M_DEVBUF);
+}
+
+/*
+ * Run exec hooks.
+ */
+void
+doexechooks(p)
+       struct proc *p;
+{
+       struct exechook_desc *edp;
+
+       for (edp = LIST_FIRST(&exechook_list); 
+            edp != NULL; 
+            edp = LIST_NEXT(edp, ehk_list)) {
+               (*edp->ehk_fn)(p, edp->ehk_arg);
+       }
+}
+
+/*
  * Determine the root device and, if instructed to, the root file system.
  */
 



Home | Main Index | Thread Index | Old Index