Module Name:    src
Committed By:   christos
Date:           Tue Oct  6 22:13:39 UTC 2015

Modified Files:
        src/sys/conf: debugsyms.c
        src/sys/kern: kern_auth.c
        src/sys/sys: kauth.h

Log Message:
Expose struct kauth_cred for the benefit of the debugger. I can't convince gcc
to produce debug info for the structure if it does not appear in more than
one source file.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/conf/debugsyms.c
cvs rdiff -u -r1.74 -r1.75 src/sys/kern/kern_auth.c
cvs rdiff -u -r1.72 -r1.73 src/sys/sys/kauth.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/conf/debugsyms.c
diff -u src/sys/conf/debugsyms.c:1.3 src/sys/conf/debugsyms.c:1.4
--- src/sys/conf/debugsyms.c:1.3	Sun Nov 22 21:13:45 2009
+++ src/sys/conf/debugsyms.c	Tue Oct  6 18:13:39 2015
@@ -1,13 +1,14 @@
-/*	$NetBSD: debugsyms.c,v 1.3 2009/11/23 02:13:45 rmind Exp $	*/
+/*	$NetBSD: debugsyms.c,v 1.4 2015/10/06 22:13:39 christos Exp $	*/
 /*
  * This file is in the public domain.
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: debugsyms.c,v 1.3 2009/11/23 02:13:45 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: debugsyms.c,v 1.4 2015/10/06 22:13:39 christos Exp $");
 
 #define	_CALLOUT_PRIVATE
 #define	__MUTEX_PRIVATE
+#define	__KAUTH_PRIVATE
 
 #include <sys/param.h>
 #include <sys/lwp.h>
@@ -22,6 +23,8 @@ __KERNEL_RCSID(0, "$NetBSD: debugsyms.c,
 #include <sys/un.h>
 #include <sys/unpcb.h>
 #include <sys/vnode.h>
+#include <sys/specificdata.h>
+#include <sys/kauth.h>
 
 /*
  * Without a dummy function referencing some of the types, gcc will
@@ -32,6 +35,7 @@ proc_t	*_debugsym_dummyfunc(vnode_t *vp)
 proc_t *
 _debugsym_dummyfunc(vnode_t *vp)
 {
+	struct kauth_cred *cr = (kauth_cred_t)vp;
 
-	return ((lwp_t *)vp->v_mount)->l_proc;
+	return cr->cr_uid ? ((lwp_t *)vp->v_mount)->l_proc : NULL;
 }

Index: src/sys/kern/kern_auth.c
diff -u src/sys/kern/kern_auth.c:1.74 src/sys/kern/kern_auth.c:1.75
--- src/sys/kern/kern_auth.c:1.74	Sat Aug  8 03:53:51 2015
+++ src/sys/kern/kern_auth.c	Tue Oct  6 18:13:39 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_auth.c,v 1.74 2015/08/08 07:53:51 mlelstv Exp $ */
+/* $NetBSD: kern_auth.c,v 1.75 2015/10/06 22:13:39 christos Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Elad Efrat <[email protected]>
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_auth.c,v 1.74 2015/08/08 07:53:51 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_auth.c,v 1.75 2015/10/06 22:13:39 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_auth.c,
 #include <sys/proc.h>
 #include <sys/ucred.h>
 #include <sys/pool.h>
+#define __KAUTH_PRIVATE
 #include <sys/kauth.h>
 #include <sys/kmem.h>
 #include <sys/rwlock.h>
@@ -54,35 +55,6 @@ struct kauth_key {
 	specificdata_key_t ks_key;	/* key */
 };
 
-/* 
- * Credentials.
- *
- * A subset of this structure is used in kvm(3) (src/lib/libkvm/kvm_proc.c)
- * and should be synchronized with this structure when the update is
- * relevant.
- */
-struct kauth_cred {
-	/*
-	 * Ensure that the first part of the credential resides in its own
-	 * cache line.  Due to sharing there aren't many kauth_creds in a
-	 * typical system, but the reference counts change very often.
-	 * Keeping it separate from the rest of the data prevents false
-	 * sharing between CPUs.
-	 */
-	u_int cr_refcnt;		/* reference count */
-#if COHERENCY_UNIT > 4
-	uint8_t cr_pad[COHERENCY_UNIT - 4];
-#endif
-	uid_t cr_uid;			/* user id */
-	uid_t cr_euid;			/* effective user id */
-	uid_t cr_svuid;			/* saved effective user id */
-	gid_t cr_gid;			/* group id */
-	gid_t cr_egid;			/* effective group id */
-	gid_t cr_svgid;			/* saved effective group id */
-	u_int cr_ngroups;		/* number of groups */
-	gid_t cr_groups[NGROUPS];	/* group memberships */
-	specificdata_reference cr_sd;	/* specific data */
-};
 
 /*
  * Listener.

Index: src/sys/sys/kauth.h
diff -u src/sys/sys/kauth.h:1.72 src/sys/sys/kauth.h:1.73
--- src/sys/sys/kauth.h:1.72	Mon Aug 17 02:16:03 2015
+++ src/sys/sys/kauth.h	Tue Oct  6 18:13:39 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: kauth.h,v 1.72 2015/08/17 06:16:03 knakahara Exp $ */
+/* $NetBSD: kauth.h,v 1.73 2015/10/06 22:13:39 christos Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Elad Efrat <[email protected]>  
@@ -54,6 +54,38 @@ typedef int (*kauth_scope_callback_t)(ka
 				      void *, void *, void *, void *, void *);
 typedef	struct kauth_key       *kauth_key_t;
 
+#ifdef __KAUTH_PRIVATE	/* For the debugger */
+/* 
+ * Credentials.
+ *
+ * A subset of this structure is used in kvm(3) (src/lib/libkvm/kvm_proc.c)
+ * and should be synchronized with this structure when the update is
+ * relevant.
+ */
+struct kauth_cred {
+	/*
+	 * Ensure that the first part of the credential resides in its own
+	 * cache line.  Due to sharing there aren't many kauth_creds in a
+	 * typical system, but the reference counts change very often.
+	 * Keeping it separate from the rest of the data prevents false
+	 * sharing between CPUs.
+	 */
+	u_int cr_refcnt;		/* reference count */
+#if COHERENCY_UNIT > 4
+	uint8_t cr_pad[COHERENCY_UNIT - 4];
+#endif
+	uid_t cr_uid;			/* user id */
+	uid_t cr_euid;			/* effective user id */
+	uid_t cr_svuid;			/* saved effective user id */
+	gid_t cr_gid;			/* group id */
+	gid_t cr_egid;			/* effective group id */
+	gid_t cr_svgid;			/* saved effective group id */
+	u_int cr_ngroups;		/* number of groups */
+	gid_t cr_groups[NGROUPS];	/* group memberships */
+	specificdata_reference cr_sd;	/* specific data */
+};
+#endif
+
 /*
  * Possible return values for a listener.
  */

Reply via email to