Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/pgoyette-compat]: src/sys Convert the compat70_unp_addsockcred hook to t...
details: https://anonhg.NetBSD.org/src/rev/5dba94b5eeb2
branches: pgoyette-compat
changeset: 445150:5dba94b5eeb2
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Mon Oct 15 11:57:05 2018 +0000
description:
Convert the compat70_unp_addsockcred hook to the MP-safe mechanism.
XXX One more remaining: sysvipc50_sysctl
diffstat:
sys/compat/common/compat_70_mod.c | 7 +++++--
sys/compat/common/uipc_usrreq_70.c | 35 ++++++++++++++++++++++++++++-------
sys/compat/sys/socket.h | 7 +++++--
sys/kern/compat_stub.c | 7 ++++++-
sys/kern/uipc_usrreq.c | 24 +++++++++++++++---------
sys/sys/compat_stub.h | 8 +++++++-
6 files changed, 66 insertions(+), 22 deletions(-)
diffs (250 lines):
diff -r 0f9be7c34be2 -r 5dba94b5eeb2 sys/compat/common/compat_70_mod.c
--- a/sys/compat/common/compat_70_mod.c Mon Oct 15 10:44:27 2018 +0000
+++ b/sys/compat/common/compat_70_mod.c Mon Oct 15 11:57:05 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_70_mod.c,v 1.1.2.11 2018/10/15 09:51:33 pgoyette Exp $ */
+/* $NetBSD: compat_70_mod.c,v 1.1.2.12 2018/10/15 11:57:05 pgoyette Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
#endif
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_70_mod.c,v 1.1.2.11 2018/10/15 09:51:33 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_70_mod.c,v 1.1.2.12 2018/10/15 11:57:05 pgoyette Exp $");
#include <sys/systm.h>
#include <sys/module.h>
@@ -49,6 +49,7 @@
#include <compat/common/compat_util.h>
#include <compat/common/compat_mod.h>
#include <compat/sys/sockio.h>
+#include <compat/sys/socket.h>
#include <compat/net/route.h>
#include <compat/net/route_70.h>
@@ -58,6 +59,7 @@
compat70_ocreds_valid = true;
rtsock_70_init();
+ uipc_usrreq_70_init();
return 0;
}
@@ -65,6 +67,7 @@
int compat_70_fini(void)
{
+ uipc_usrreq_70_fini();
rtsock_70_fini();
compat70_ocreds_valid = false;
diff -r 0f9be7c34be2 -r 5dba94b5eeb2 sys/compat/common/uipc_usrreq_70.c
--- a/sys/compat/common/uipc_usrreq_70.c Mon Oct 15 10:44:27 2018 +0000
+++ b/sys/compat/common/uipc_usrreq_70.c Mon Oct 15 11:57:05 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_usrreq_70.c,v 1.1.20.2 2018/09/22 04:56:28 pgoyette Exp $ */
+/* $NetBSD: uipc_usrreq_70.c,v 1.1.20.3 2018/10/15 11:57:05 pgoyette Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq_70.c,v 1.1.20.2 2018/09/22 04:56:28 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq_70.c,v 1.1.20.3 2018/10/15 11:57:05 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -43,11 +43,12 @@
#include <sys/unpcb.h>
#include <sys/mbuf.h>
#include <sys/kauth.h>
+#include <sys/compat_stub.h>
#include <compat/sys/socket.h>
-struct mbuf *
-compat_70_unp_addsockcred(struct lwp *l, struct mbuf *control)
+int
+compat_70_unp_addsockcred(struct mbuf **ret, struct lwp *l, struct mbuf *control)
{
struct sockcred70 *sc;
struct mbuf *m;
@@ -55,8 +56,10 @@
m = sbcreatecontrol1(&p, SOCKCRED70SIZE(kauth_cred_ngroups(l->l_cred)),
SCM_OCREDS, SOL_SOCKET, M_WAITOK);
- if (m == NULL)
- return control;
+ if (m == NULL) {
+ *ret = control;
+ return 0;
+ }
sc = p;
sc->sc_uid = kauth_cred_getuid(l->l_cred);
@@ -68,5 +71,23 @@
for (int i = 0; i < sc->sc_ngroups; i++)
sc->sc_groups[i] = kauth_cred_group(l->l_cred, i);
- return m_add(control, m);
+ *ret = m_add(control, m);
+ return 0;
}
+
+MODULE_SET_HOOK(compat_70_unp_hook, "unp_70", compat_70_unp_addsockcred);
+MODULE_UNSET_HOOK(compat_70_unp_hook);
+
+void
+uipc_usrreq_70_init(void)
+{
+
+ compat_70_unp_hook_set();
+}
+
+void
+uipc_usrreq_70_fini(void)
+{
+
+ compat_70_unp_hook_unset();
+}
diff -r 0f9be7c34be2 -r 5dba94b5eeb2 sys/compat/sys/socket.h
--- a/sys/compat/sys/socket.h Mon Oct 15 10:44:27 2018 +0000
+++ b/sys/compat/sys/socket.h Mon Oct 15 11:57:05 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: socket.h,v 1.15 2017/07/29 06:12:50 maxv Exp $ */
+/* $NetBSD: socket.h,v 1.15.2.1 2018/10/15 11:57:05 pgoyette Exp $ */
/*
* Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
@@ -105,7 +105,10 @@
int compat_ifioctl(struct socket *, u_long, u_long, void *, struct lwp *);
int compat43_set_accrights(struct msghdr *, void *, int);
-struct mbuf * compat_70_unp_addsockcred(struct lwp *, struct mbuf *);
+int compat_70_unp_addsockcred(struct mbuf **, struct lwp *, struct mbuf *);
+
+void uipc_usrreq_70_init(void);
+void uipc_usrreq_70_fini(void);
__END_DECLS
#else
int __socket30(int, int, int);
diff -r 0f9be7c34be2 -r 5dba94b5eeb2 sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c Mon Oct 15 10:44:27 2018 +0000
+++ b/sys/kern/compat_stub.c Mon Oct 15 11:57:05 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.30 2018/10/15 10:44:27 pgoyette Exp $ */
+/* $NetBSD: compat_stub.c,v 1.1.2.31 2018/10/15 11:57:05 pgoyette Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -198,3 +198,8 @@
*/
struct compat_10_openat_hook_t compat_10_openat_hook;
+/*
+ * Hook for compat_70_unp_addsockcred
+ */
+struct compat_70_unp_hook_t compat_70_unp_hook;
+
diff -r 0f9be7c34be2 -r 5dba94b5eeb2 sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c Mon Oct 15 10:44:27 2018 +0000
+++ b/sys/kern/uipc_usrreq.c Mon Oct 15 11:57:05 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_usrreq.c,v 1.183.2.4 2018/10/15 09:51:34 pgoyette Exp $ */
+/* $NetBSD: uipc_usrreq.c,v 1.183.2.5 2018/10/15 11:57:05 pgoyette Exp $ */
/*-
* Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.183.2.4 2018/10/15 09:51:34 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.183.2.5 2018/10/15 11:57:05 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -123,6 +123,7 @@
#include <sys/uidinfo.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
+#include <sys/compat_stub.h>
#include <compat/sys/socket.h>
@@ -197,16 +198,15 @@
/* Compat interface */
-static struct mbuf *stub_compat_70_unp_addsockcred(lwp_t *, struct mbuf *);
-struct mbuf *(*vec_compat_70_unp_addsockcred)(struct lwp *, struct mbuf *) =
- stub_compat_70_unp_addsockcred;
+int stub_compat_70_unp_addsockcred(struct mbuf **, lwp_t *, struct mbuf *);
-struct mbuf *stub_compat_70_unp_addsockcred(struct lwp *lwp,
+int stub_compat_70_unp_addsockcred(struct mbuf** ret, struct lwp *lwp,
struct mbuf *control)
{
/* just return our initial argument */
- return control;
+ *ret = control;
+ return 0;
}
bool *compat70_ocreds_valid = false;
@@ -331,6 +331,12 @@
kmem_free(unp, sizeof(*unp));
}
+MODULE_CALL_HOOK_DECL(compat_70_unp_hook, f,
+ (struct mbuf **, struct lwp *, struct mbuf *));
+MODULE_CALL_HOOK(compat_70_unp_hook, f,
+ (struct mbuf **ret, struct lwp *lwp, struct mbuf *control),
+ (ret, lwp, control), stub_compat_70_unp_addsockcred(ret, lwp, control));
+
static int
unp_output(struct mbuf *m, struct mbuf *control, struct unpcb *unp)
{
@@ -351,7 +357,7 @@
if (unp->unp_conn->unp_flags & UNP_WANTCRED)
control = unp_addsockcred(curlwp, control);
if (unp->unp_conn->unp_flags & UNP_OWANTCRED)
- control = (*vec_compat_70_unp_addsockcred)(curlwp, control);
+ compat_70_unp_hook_f_call(&control, curlwp, control);
if (sbappendaddr(&so2->so_rcv, (const struct sockaddr *)sun, m,
control) == 0) {
unp_dispose(control);
@@ -530,7 +536,7 @@
* SOCK_STREAM and SOCK_SEQPACKET.
*/
unp->unp_conn->unp_flags &= ~UNP_OWANTCRED;
- control = (*vec_compat_70_unp_addsockcred)(l, control);
+ compat_70_unp_hook_f_call(&control, curlwp, control);
}
/*
* Send to paired receive port, and then reduce
diff -r 0f9be7c34be2 -r 5dba94b5eeb2 sys/sys/compat_stub.h
--- a/sys/sys/compat_stub.h Mon Oct 15 10:44:27 2018 +0000
+++ b/sys/sys/compat_stub.h Mon Oct 15 11:57:05 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.1.2.42 2018/10/15 10:44:28 pgoyette Exp $ */
+/* $NetBSD: compat_stub.h,v 1.1.2.43 2018/10/15 11:57:05 pgoyette Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -251,4 +251,10 @@
struct pathbuf;
MODULE_HOOK(compat_10_openat_hook, (struct pathbuf **));
+/*
+ * Hook for compat_70_unp_addsockcred
+ */
+struct mbuf;
+MODULE_HOOK(compat_70_unp_hook, (struct mbuf **, struct lwp *, struct mbuf *));
+
#endif /* _SYS_COMPAT_STUB_H */
Home |
Main Index |
Thread Index |
Old Index