summaryrefslogtreecommitdiff
path: root/sys/nfs/nfs_subs.c
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2016-04-29 14:40:37 +0000
committerBob Beck <beck@cvs.openbsd.org>2016-04-29 14:40:37 +0000
commitf4bcd1acc00bfdb816780ce4ec8c6a0771db7e48 (patch)
tree9195aa1d7c4e3f2c7634ace105c90bddcedc4f5e /sys/nfs/nfs_subs.c
parent3e2a80372cf7ab1ece40b6e7efb0ce2b7ccb409f (diff)
Fix some gibbering horrors due to uninitialized struct nameidata's
1) turn NDINITAT into a function and make the macros point to it with the later goal of getting rid of them. 2) Sweep the kernel for places where people make a struct nameidata manually on the stack and fill in what they hope are the required fields and count on prayer and clean living to always get them right. Instead use NDINIT everywhere. NFS was especially bad for this and there have likely been things lurking there for a while. 3) Add a couple of strategic KASSERT's to catch future offenders. ok krw@ sthen@ deraadt@
Diffstat (limited to 'sys/nfs/nfs_subs.c')
-rw-r--r--sys/nfs/nfs_subs.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c
index 97f7d6e8352..35ad17e64fb 100644
--- a/sys/nfs/nfs_subs.c
+++ b/sys/nfs/nfs_subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_subs.c,v 1.130 2016/03/19 12:04:16 natano Exp $ */
+/* $OpenBSD: nfs_subs.c,v 1.131 2016/04/29 14:40:36 beck Exp $ */
/* $NetBSD: nfs_subs.c,v 1.27.4.3 1996/07/08 20:34:24 jtc Exp $ */
/*
@@ -1244,6 +1244,13 @@ nfs_namei(struct nameidata *ndp, fhandle_t *fhp, int len,
cnp->cn_flags |= (NOCROSSMOUNT | RDONLY);
else
cnp->cn_flags |= NOCROSSMOUNT;
+
+ /*
+ * Should be 0, if not someone didn't init ndp with NDINIT,
+ * go find and murder the offender messily.
+ */
+ KASSERT (ndp->ni_p_path == NULL && ndp->ni_p_size == 0);
+
/*
* And call lookup() to do the real work
*/