CVS commit: src/sys/nfs

2024-02-13 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Feb 13 21:40:02 UTC 2024

Modified Files:
src/sys/nfs: nfs_bio.c

Log Message:
s/Enque/Enqueue/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 src/sys/nfs/nfs_bio.c

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

Modified files:

Index: src/sys/nfs/nfs_bio.c
diff -u src/sys/nfs/nfs_bio.c:1.201 src/sys/nfs/nfs_bio.c:1.202
--- src/sys/nfs/nfs_bio.c:1.201	Fri Jun 24 16:50:00 2022
+++ src/sys/nfs/nfs_bio.c	Tue Feb 13 21:40:02 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bio.c,v 1.201 2022/06/24 16:50:00 hannken Exp $	*/
+/*	$NetBSD: nfs_bio.c,v 1.202 2024/02/13 21:40:02 andvar Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.201 2022/06/24 16:50:00 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.202 2024/02/13 21:40:02 andvar Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -799,7 +799,7 @@ again:
 		 * Ensure that the queue never grows too large.
 		 */
 		if (curlwp == uvm.pagedaemon_lwp) {
-	  		/* Enque for later, to avoid free-page deadlock */
+	  		/* Enqueue for later, to avoid free-page deadlock */
 		} else while (nmp->nm_bufqlen >= 2 * nmp->nm_bufqiods) {
 			if (catch_p) {
 error = cv_timedwait_sig(>nm_aiocv,



CVS commit: src/sys/nfs

2024-02-13 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Feb 13 21:40:02 UTC 2024

Modified Files:
src/sys/nfs: nfs_bio.c

Log Message:
s/Enque/Enqueue/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 src/sys/nfs/nfs_bio.c

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



CVS commit: src/sys/nfs

2023-12-10 Thread Amitai Schleier
Module Name:src
Committed By:   schmonz
Date:   Sun Dec 10 18:16:08 UTC 2023

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
NFS client: fix interop with macOS 14 servers.

Symptom: a bunch of "Cannot open `.' (Invalid argument)".

thorpej@ analysis and fix: on the first request to read a given
directory, make sure READDIR and READDIRPLUS cookie verifiers are
being set to 0. This is in RFC1813 and macOS must have gotten
stricter about it.

Verified on 10.0_RC1/aarch64 to fix the reproducers in PR kern/57691 as
well as the original use case in which I met the bug: pkg_rr once again
runs to completion.


To generate a diff of this commit:
cvs rdiff -u -r1.324 -r1.325 src/sys/nfs/nfs_vnops.c

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

Modified files:

Index: src/sys/nfs/nfs_vnops.c
diff -u src/sys/nfs/nfs_vnops.c:1.324 src/sys/nfs/nfs_vnops.c:1.325
--- src/sys/nfs/nfs_vnops.c:1.324	Tue May 24 06:28:02 2022
+++ src/sys/nfs/nfs_vnops.c	Sun Dec 10 18:16:08 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.324 2022/05/24 06:28:02 andvar Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.325 2023/12/10 18:16:08 schmonz Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.324 2022/05/24 06:28:02 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.325 2023/12/10 18:16:08 schmonz Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -2422,8 +2422,13 @@ nfs_readdirrpc(struct vnode *vp, struct 
 txdr_cookie3(uiop->uio_offset, tl);
 			}
 			tl += 2;
-			*tl++ = dnp->n_cookieverf.nfsuquad[0];
-			*tl++ = dnp->n_cookieverf.nfsuquad[1];
+			if (uiop->uio_offset == 0) {
+*tl++ = 0;
+*tl++ = 0;
+			} else {
+*tl++ = dnp->n_cookieverf.nfsuquad[0];
+*tl++ = dnp->n_cookieverf.nfsuquad[1];
+			}
 		} else
 #endif
 		{
@@ -2632,8 +2637,13 @@ nfs_readdirplusrpc(struct vnode *vp, str
 			txdr_cookie3(uiop->uio_offset, tl);
 		}
 		tl += 2;
-		*tl++ = dnp->n_cookieverf.nfsuquad[0];
-		*tl++ = dnp->n_cookieverf.nfsuquad[1];
+		if (uiop->uio_offset == 0) {
+			*tl++ = 0;
+			*tl++ = 0;
+		} else {
+			*tl++ = dnp->n_cookieverf.nfsuquad[0];
+			*tl++ = dnp->n_cookieverf.nfsuquad[1];
+		}
 		*tl++ = txdr_unsigned(nmp->nm_readdirsize);
 		*tl = txdr_unsigned(nmp->nm_rsize);
 		nfsm_request(dnp, NFSPROC_READDIRPLUS, curlwp, cred);



CVS commit: src/sys/nfs

2023-12-10 Thread Amitai Schleier
Module Name:src
Committed By:   schmonz
Date:   Sun Dec 10 18:16:08 UTC 2023

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
NFS client: fix interop with macOS 14 servers.

Symptom: a bunch of "Cannot open `.' (Invalid argument)".

thorpej@ analysis and fix: on the first request to read a given
directory, make sure READDIR and READDIRPLUS cookie verifiers are
being set to 0. This is in RFC1813 and macOS must have gotten
stricter about it.

Verified on 10.0_RC1/aarch64 to fix the reproducers in PR kern/57691 as
well as the original use case in which I met the bug: pkg_rr once again
runs to completion.


To generate a diff of this commit:
cvs rdiff -u -r1.324 -r1.325 src/sys/nfs/nfs_vnops.c

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



CVS commit: src/sys/nfs

2023-04-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr  9 12:33:58 UTC 2023

Modified Files:
src/sys/nfs: nfs_socket.c

Log Message:
nfs: Simplify assertion.  No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/sys/nfs/nfs_socket.c

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

Modified files:

Index: src/sys/nfs/nfs_socket.c
diff -u src/sys/nfs/nfs_socket.c:1.200 src/sys/nfs/nfs_socket.c:1.201
--- src/sys/nfs/nfs_socket.c:1.200	Mon Sep  3 16:29:36 2018
+++ src/sys/nfs/nfs_socket.c	Sun Apr  9 12:33:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.200 2018/09/03 16:29:36 riastradh Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.201 2023/04/09 12:33:58 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.200 2018/09/03 16:29:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.201 2023/04/09 12:33:58 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -1229,8 +1229,8 @@ nfs_getreq(struct nfsrv_descript *nd, st
 
 	nd->nd_md = md;
 	nd->nd_dpos = dpos;
-	KASSERT((nd->nd_cr == NULL && (nfsd->nfsd_flag & NFSD_NEEDAUTH) != 0)
-	 || (nd->nd_cr != NULL && (nfsd->nfsd_flag & NFSD_NEEDAUTH) == 0));
+	KASSERT((nd->nd_cr == NULL) ==
+	((nfsd->nfsd_flag & NFSD_NEEDAUTH) != 0));
 	return (0);
 nfsmout:
 errout:



CVS commit: src/sys/nfs

2023-04-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr  9 12:33:58 UTC 2023

Modified Files:
src/sys/nfs: nfs_socket.c

Log Message:
nfs: Simplify assertion.  No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/sys/nfs/nfs_socket.c

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



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:53:02 UTC 2023

Modified Files:
src/sys/nfs: nfs_serv.c

Log Message:
nfs: Avoid free of uninitialized on bad name size in create, mknod.

XXX These error branches are a nightmare and need to be more
systematically cleaned up.  Even if they are correct now, they are
impossible to audit and extremely fragile in case anyone ever needs
to make other changes to them.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/sys/nfs/nfs_serv.c

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

Modified files:

Index: src/sys/nfs/nfs_serv.c
diff -u src/sys/nfs/nfs_serv.c:1.183 src/sys/nfs/nfs_serv.c:1.184
--- src/sys/nfs/nfs_serv.c:1.183	Wed Apr 27 17:38:52 2022
+++ src/sys/nfs/nfs_serv.c	Thu Mar 23 19:53:01 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.184 2023/03/23 19:53:01 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.184 2023/03/23 19:53:01 riastradh Exp $");
 
 #include 
 #include 
@@ -1648,10 +1648,10 @@ nfsmout:
 			vput(nd.ni_dvp);
 		if (nd.ni_vp)
 			vput(nd.ni_vp);
-	}
-	if (nd.ni_pathbuf != NULL) {
-		pathbuf_destroy(nd.ni_pathbuf);
-		nd.ni_pathbuf = NULL;
+		if (nd.ni_pathbuf != NULL) {
+			pathbuf_destroy(nd.ni_pathbuf);
+			nd.ni_pathbuf = NULL;
+		}
 	}
 	return (error);
 }
@@ -1801,10 +1801,10 @@ nfsmout:
 			vput(nd.ni_dvp);
 		if (nd.ni_vp)
 			vput(nd.ni_vp);
-	}
-	if (nd.ni_pathbuf != NULL) {
-		pathbuf_destroy(nd.ni_pathbuf);
-		nd.ni_pathbuf = NULL;
+		if (nd.ni_pathbuf != NULL) {
+			pathbuf_destroy(nd.ni_pathbuf);
+			nd.ni_pathbuf = NULL;
+		}
 	}
 	if (dirp)
 		vrele(dirp);



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:53:02 UTC 2023

Modified Files:
src/sys/nfs: nfs_serv.c

Log Message:
nfs: Avoid free of uninitialized on bad name size in create, mknod.

XXX These error branches are a nightmare and need to be more
systematically cleaned up.  Even if they are correct now, they are
impossible to audit and extremely fragile in case anyone ever needs
to make other changes to them.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/sys/nfs/nfs_serv.c

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



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:52 UTC 2023

Modified Files:
src/sys/nfs: nfsm_subs.h

Log Message:
nfs: Use unsigned name lengths so we don't trip over negative ones.

- nfsm_strsiz is only used with uint32_t in callers, but let's not
  leave it as a rake to step on.

- nfsm_srvnamesiz is abused with signed s.  The internal conversion
  to unsigned serves to reject both negative and too-large values in
  such callers.

  XXX Should make all callers use unsigned, rather than flipping back
  and forth between signed and unsigned for name lengths.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/nfs/nfsm_subs.h

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



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:52 UTC 2023

Modified Files:
src/sys/nfs: nfsm_subs.h

Log Message:
nfs: Use unsigned name lengths so we don't trip over negative ones.

- nfsm_strsiz is only used with uint32_t in callers, but let's not
  leave it as a rake to step on.

- nfsm_srvnamesiz is abused with signed s.  The internal conversion
  to unsigned serves to reject both negative and too-large values in
  such callers.

  XXX Should make all callers use unsigned, rather than flipping back
  and forth between signed and unsigned for name lengths.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/nfs/nfsm_subs.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/nfs/nfsm_subs.h
diff -u src/sys/nfs/nfsm_subs.h:1.56 src/sys/nfs/nfsm_subs.h:1.57
--- src/sys/nfs/nfsm_subs.h:1.56	Thu Mar 23 19:52:33 2023
+++ src/sys/nfs/nfsm_subs.h	Thu Mar 23 19:52:52 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfsm_subs.h,v 1.56 2023/03/23 19:52:33 riastradh Exp $	*/
+/*	$NetBSD: nfsm_subs.h,v 1.57 2023/03/23 19:52:52 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -366,7 +366,7 @@
 
 #define	nfsm_strsiz(s,m) \
 		{ nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
-		if (((s) = fxdr_unsigned(uint32_t,*tl)) > (m)) { \
+		if ((uint32_t)((s) = fxdr_unsigned(uint32_t,*tl)) > (m)) { \
 			m_freem(mrep); \
 			error = EBADRPC; \
 			goto nfsmout; \
@@ -374,7 +374,8 @@
 
 #define	nfsm_srvnamesiz(s) \
 		{ nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
-		if (((s) = fxdr_unsigned(uint32_t,*tl)) > NFS_MAXNAMLEN) \
+		if ((uint32_t)((s) = fxdr_unsigned(uint32_t,*tl)) > \
+		NFS_MAXNAMLEN) \
 			error = NFSERR_NAMETOL; \
 		if (error) \
 			nfsm_reply(0); \



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:43 UTC 2023

Modified Files:
src/sys/nfs: nfs_srvsubs.c

Log Message:
nfs: Avoid integer overflow in nfs_namei bounds check.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/nfs/nfs_srvsubs.c

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

Modified files:

Index: src/sys/nfs/nfs_srvsubs.c
diff -u src/sys/nfs/nfs_srvsubs.c:1.16 src/sys/nfs/nfs_srvsubs.c:1.17
--- src/sys/nfs/nfs_srvsubs.c:1.16	Wed Apr 27 17:38:52 2022
+++ src/sys/nfs/nfs_srvsubs.c	Thu Mar 23 19:52:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_srvsubs.c,v 1.16 2022/04/27 17:38:52 hannken Exp $	*/
+/*	$NetBSD: nfs_srvsubs.c,v 1.17 2023/03/23 19:52:42 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_srvsubs.c,v 1.16 2022/04/27 17:38:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_srvsubs.c,v 1.17 2023/03/23 19:52:42 riastradh Exp $");
 
 #include 
 #include 
@@ -129,7 +129,7 @@ nfs_namei(struct nameidata *ndp, nfsrvfh
 	*retdirp = NULL;
 	ndp->ni_pathbuf = NULL;
 
-	if ((len + 1) > NFS_MAXPATHLEN)
+	if (len > NFS_MAXPATHLEN - 1)
 		return (ENAMETOOLONG);
 	if (len == 0)
 		return (EACCES);



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:33 UTC 2023

Modified Files:
src/sys/nfs: nfsm_subs.h

Log Message:
nfs: Use unsigned fhlen so we don't trip over negative values.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/nfs/nfsm_subs.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/nfs/nfsm_subs.h
diff -u src/sys/nfs/nfsm_subs.h:1.55 src/sys/nfs/nfsm_subs.h:1.56
--- src/sys/nfs/nfsm_subs.h:1.55	Thu Aug 12 20:25:27 2021
+++ src/sys/nfs/nfsm_subs.h	Thu Mar 23 19:52:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfsm_subs.h,v 1.55 2021/08/12 20:25:27 andvar Exp $	*/
+/*	$NetBSD: nfsm_subs.h,v 1.56 2023/03/23 19:52:33 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -480,20 +480,24 @@
 		} }
 
 #define nfsm_srvmtofh(nsfh) \
-	{ int fhlen = NFSX_V3FH; \
+	{ uint32_t fhlen = NFSX_V3FH; \
 		if (nfsd->nd_flag & ND_NFSV3) { \
-			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
-			fhlen = fxdr_unsigned(int, *tl); \
+			nfsm_dissect(tl, uint32_t *, NFSX_UNSIGNED); \
+			fhlen = fxdr_unsigned(uint32_t, *tl); \
+			CTASSERT(NFSX_V3FHMAX <= FHANDLE_SIZE_MAX); \
 			if (fhlen > NFSX_V3FHMAX || \
 			(fhlen < FHANDLE_SIZE_MIN && fhlen > 0)) { \
 error = EBADRPC; \
 nfsm_reply(0); \
 			} \
 		} else { \
+			CTASSERT(NFSX_V2FH >= FHANDLE_SIZE_MIN); \
 			fhlen = NFSX_V2FH; \
 		} \
 		(nsfh)->nsfh_size = fhlen; \
 		if (fhlen != 0) { \
+			KASSERT(fhlen >= FHANDLE_SIZE_MIN); \
+			KASSERT(fhlen <= FHANDLE_SIZE_MAX); \
 			nfsm_dissect(tl, u_int32_t *, fhlen); \
 			memcpy(NFSRVFH_DATA(nsfh), tl, fhlen); \
 		} \



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:33 UTC 2023

Modified Files:
src/sys/nfs: nfsm_subs.h

Log Message:
nfs: Use unsigned fhlen so we don't trip over negative values.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/nfs/nfsm_subs.h

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



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:43 UTC 2023

Modified Files:
src/sys/nfs: nfs_srvsubs.c

Log Message:
nfs: Avoid integer overflow in nfs_namei bounds check.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/nfs/nfs_srvsubs.c

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



CVS commit: src/sys/nfs

2023-03-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 21 15:47:46 UTC 2023

Modified Files:
src/sys/nfs: nfs_clntsubs.c nfs_iod.c nfs_vfsops.c

Log Message:
PR/57279: Izumi Tsutsui: Fix some {int,long} -> time_t. Still things will
break eventually because parts of the nfs protocol assume time_t will fit
in 32 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/nfs/nfs_clntsubs.c
cvs rdiff -u -r1.8 -r1.9 src/sys/nfs/nfs_iod.c
cvs rdiff -u -r1.244 -r1.245 src/sys/nfs/nfs_vfsops.c

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

Modified files:

Index: src/sys/nfs/nfs_clntsubs.c
diff -u src/sys/nfs/nfs_clntsubs.c:1.6 src/sys/nfs/nfs_clntsubs.c:1.7
--- src/sys/nfs/nfs_clntsubs.c:1.6	Mon Feb 28 03:45:36 2022
+++ src/sys/nfs/nfs_clntsubs.c	Tue Mar 21 11:47:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clntsubs.c,v 1.6 2022/02/28 08:45:36 hannken Exp $	*/
+/*	$NetBSD: nfs_clntsubs.c,v 1.7 2023/03/21 15:47:46 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.6 2022/02/28 08:45:36 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.7 2023/03/21 15:47:46 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -390,7 +390,7 @@ nfs_check_wccdata(struct nfsnode *np, co
 	if (docheck) {
 		struct vnode *vp = NFSTOV(np);
 		struct nfsmount *nmp;
-		long now = time_second;
+		time_t now = time_second;
 		const struct timespec *omtime = >n_vattr->va_mtime;
 		const struct timespec *octime = >n_vattr->va_ctime;
 		const char *reason = NULL; /* XXX: gcc */

Index: src/sys/nfs/nfs_iod.c
diff -u src/sys/nfs/nfs_iod.c:1.8 src/sys/nfs/nfs_iod.c:1.9
--- src/sys/nfs/nfs_iod.c:1.8	Mon Sep  3 12:29:36 2018
+++ src/sys/nfs/nfs_iod.c	Tue Mar 21 11:47:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_iod.c,v 1.8 2018/09/03 16:29:36 riastradh Exp $	*/
+/*	$NetBSD: nfs_iod.c,v 1.9 2023/03/21 15:47:46 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_iod.c,v 1.8 2018/09/03 16:29:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_iod.c,v 1.9 2023/03/21 15:47:46 christos Exp $");
 
 #include 
 #include 
@@ -409,7 +409,8 @@ nfs_savenickauth(struct nfsmount *nmp, k
 	struct timeval ktvin, ktvout;
 	u_int32_t nick;
 	char *dpos = *dposp, *cp2;
-	int deltasec, error = 0;
+	time_t deltasec;
+	int error = 0;
 
 	memset(, 0, sizeof ktvout);	 /* XXX gcc */
 

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.244 src/sys/nfs/nfs_vfsops.c:1.245
--- src/sys/nfs/nfs_vfsops.c:1.244	Thu Mar 16 20:46:35 2023
+++ src/sys/nfs/nfs_vfsops.c	Tue Mar 21 11:47:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.244 2023/03/17 00:46:35 mlelstv Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.245 2023/03/21 15:47:46 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.244 2023/03/17 00:46:35 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.245 2023/03/21 15:47:46 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -323,7 +323,7 @@ nfs_mountroot(void)
 	struct mount *mp;
 	struct vnode *vp;
 	struct lwp *l;
-	long n;
+	time_t n;
 	int error;
 
 	l = curlwp; /* XXX */
@@ -378,7 +378,7 @@ nfs_mountroot(void)
 		panic("nfs_mountroot: getattr for root");
 	n = attr.va_atime.tv_sec;
 #ifdef	DEBUG
-	printf("root time: 0x%lx\n", n);
+	printf("root time: 0x%jx\n", (intmax_t)n);
 #endif
 	setrootfstime(n);
 



CVS commit: src/sys/nfs

2023-03-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 21 15:47:46 UTC 2023

Modified Files:
src/sys/nfs: nfs_clntsubs.c nfs_iod.c nfs_vfsops.c

Log Message:
PR/57279: Izumi Tsutsui: Fix some {int,long} -> time_t. Still things will
break eventually because parts of the nfs protocol assume time_t will fit
in 32 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/nfs/nfs_clntsubs.c
cvs rdiff -u -r1.8 -r1.9 src/sys/nfs/nfs_iod.c
cvs rdiff -u -r1.244 -r1.245 src/sys/nfs/nfs_vfsops.c

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



CVS commit: src/sys/nfs

2023-03-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Mar 17 00:46:35 UTC 2023

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Avoid overflow of nfs_commitsize on machines with > 32GB RAM.


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.244 src/sys/nfs/nfs_vfsops.c

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

Modified files:

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.243 src/sys/nfs/nfs_vfsops.c:1.244
--- src/sys/nfs/nfs_vfsops.c:1.243	Sun Jun 13 10:25:11 2021
+++ src/sys/nfs/nfs_vfsops.c	Fri Mar 17 00:46:35 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.243 2021/06/13 10:25:11 mlelstv Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.244 2023/03/17 00:46:35 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.243 2021/06/13 10:25:11 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.244 2023/03/17 00:46:35 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -1135,6 +1135,7 @@ nfs_start(struct mount *mp, int flags)
 void
 nfs_vfs_init(void)
 {
+	unsigned scale;
 
 	/* Initialize NFS server / client shared data. */
 	nfs_init();
@@ -1145,7 +1146,8 @@ nfs_vfs_init(void)
 	/* Initialize the iod structures */
 	nfs_iodinit();
 
-	nfs_commitsize = uvmexp.npages << (PAGE_SHIFT - 4);
+	scale = PAGE_SHIFT - 4;
+	nfs_commitsize = uimin(uvmexp.npages, INT_MAX >> scale) << scale;
 }
 
 void



CVS commit: src/sys/nfs

2023-03-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Mar 17 00:46:35 UTC 2023

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Avoid overflow of nfs_commitsize on machines with > 32GB RAM.


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.244 src/sys/nfs/nfs_vfsops.c

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



CVS commit: src/sys/nfs

2022-12-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Dec 24 15:37:50 UTC 2022

Modified Files:
src/sys/nfs: nfs_bootdhcp.c

Log Message:
s/reqest/request/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/nfs/nfs_bootdhcp.c

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

Modified files:

Index: src/sys/nfs/nfs_bootdhcp.c
diff -u src/sys/nfs/nfs_bootdhcp.c:1.56 src/sys/nfs/nfs_bootdhcp.c:1.57
--- src/sys/nfs/nfs_bootdhcp.c:1.56	Fri Jun 10 13:27:16 2016
+++ src/sys/nfs/nfs_bootdhcp.c	Sat Dec 24 15:37:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bootdhcp.c,v 1.56 2016/06/10 13:27:16 ozaki-r Exp $	*/
+/*	$NetBSD: nfs_bootdhcp.c,v 1.57 2022/12/24 15:37:50 andvar Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_bootdhcp.c,v 1.56 2016/06/10 13:27:16 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_bootdhcp.c,v 1.57 2022/12/24 15:37:50 andvar Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs_boot.h"
@@ -600,7 +600,7 @@ bootpc_call(struct nfs_diskless *nd, str
 	m_reset_rcvif(m);
 
 	/*
-	 * Build the BOOTP reqest message.
+	 * Build the BOOTP request message.
 	 * Note: xid is host order! (opaque to server)
 	 */
 	memset((void *)bootp, 0, BOOTP_SIZE_MAX);



CVS commit: src/sys/nfs

2022-12-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Dec 24 15:37:50 UTC 2022

Modified Files:
src/sys/nfs: nfs_bootdhcp.c

Log Message:
s/reqest/request/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/nfs/nfs_bootdhcp.c

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



CVS commit: src/sys/nfs

2022-12-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Dec 20 09:40:09 UTC 2022

Modified Files:
src/sys/nfs: nfs_srvsocket.c

Log Message:
When partitioning a mbuf chain with m_split() the last mbuf of the returned
tail chain is not necessarily the same as the last mbuf of the initial chain.

Always set "slp->ns_rawend" to the last mbuf of the tail chain to prevent
mbuf leaks and corruption.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/nfs/nfs_srvsocket.c

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

Modified files:

Index: src/sys/nfs/nfs_srvsocket.c
diff -u src/sys/nfs/nfs_srvsocket.c:1.4 src/sys/nfs/nfs_srvsocket.c:1.5
--- src/sys/nfs/nfs_srvsocket.c:1.4	Thu Sep  3 20:59:12 2009
+++ src/sys/nfs/nfs_srvsocket.c	Tue Dec 20 09:40:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_srvsocket.c,v 1.4 2009/09/03 20:59:12 tls Exp $	*/
+/*	$NetBSD: nfs_srvsocket.c,v 1.5 2022/12/20 09:40:09 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_srvsocket.c,v 1.4 2009/09/03 20:59:12 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_srvsocket.c,v 1.5 2022/12/20 09:40:09 hannken Exp $");
 
 #include 
 #include 
@@ -323,8 +323,9 @@ nfsrv_getstream(struct nfssvc_sock *slp,
 			}
 			m_claimm(recm, _mowner);
 			slp->ns_raw = m;
-			if (m->m_next == NULL)
-slp->ns_rawend = m;
+			while (m->m_next)
+m = m->m_next;
+			slp->ns_rawend = m;
 			slp->ns_cc -= slp->ns_reclen;
 			slp->ns_reclen = 0;
 		} else {



CVS commit: src/sys/nfs

2022-12-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Dec 20 09:40:09 UTC 2022

Modified Files:
src/sys/nfs: nfs_srvsocket.c

Log Message:
When partitioning a mbuf chain with m_split() the last mbuf of the returned
tail chain is not necessarily the same as the last mbuf of the initial chain.

Always set "slp->ns_rawend" to the last mbuf of the tail chain to prevent
mbuf leaks and corruption.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/nfs/nfs_srvsocket.c

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



CVS commit: src/sys/nfs

2022-06-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun 24 16:50:00 UTC 2022

Modified Files:
src/sys/nfs: nfs_bio.c

Log Message:
Remove an incorrect assertion.

Just issue a readahead near the end of the vnode and enqueue an async read.
Now let nfs_setattr() truncate the vnode, set its new size and
nfs_vinvalbuf() waits for the pages from the readahead to become unbusy.

The async read gets processed and returns with uio_resid > 0 because there
is a hole and no write after the hole has been pushed yet.  As the vnode
size already got truncated to the new size the KASSERT() incorrectly fires.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/sys/nfs/nfs_bio.c

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

Modified files:

Index: src/sys/nfs/nfs_bio.c
diff -u src/sys/nfs/nfs_bio.c:1.200 src/sys/nfs/nfs_bio.c:1.201
--- src/sys/nfs/nfs_bio.c:1.200	Wed Oct 20 03:08:18 2021
+++ src/sys/nfs/nfs_bio.c	Fri Jun 24 16:50:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bio.c,v 1.200 2021/10/20 03:08:18 thorpej Exp $	*/
+/*	$NetBSD: nfs_bio.c,v 1.201 2022/06/24 16:50:00 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.200 2021/10/20 03:08:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.201 2022/06/24 16:50:00 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -878,8 +878,6 @@ nfs_doio_read(struct buf *bp, struct uio
 			 * Just zero fill the rest of the valid area.
 			 */
 
-			KASSERT(vp->v_size >=
-			uiop->uio_offset + uiop->uio_resid);
 			diff = bp->b_bcount - uiop->uio_resid;
 			len = uiop->uio_resid;
 			memset((char *)bp->b_data + diff, 0, len);



CVS commit: src/sys/nfs

2022-06-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun 24 16:50:00 UTC 2022

Modified Files:
src/sys/nfs: nfs_bio.c

Log Message:
Remove an incorrect assertion.

Just issue a readahead near the end of the vnode and enqueue an async read.
Now let nfs_setattr() truncate the vnode, set its new size and
nfs_vinvalbuf() waits for the pages from the readahead to become unbusy.

The async read gets processed and returns with uio_resid > 0 because there
is a hole and no write after the hole has been pushed yet.  As the vnode
size already got truncated to the new size the KASSERT() incorrectly fires.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/sys/nfs/nfs_bio.c

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



CVS commit: src/sys/nfs

2022-04-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr 27 17:38:52 UTC 2022

Modified Files:
src/sys/nfs: nfs_serv.c nfs_srvsubs.c nfs_var.h

Log Message:
As VOP_GETATTR() needs a shared lock at least move the preopattr lookup
inside nfs_namei() where we may lock the start directory without violating
the lock order.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.15 -r1.16 src/sys/nfs/nfs_srvsubs.c
cvs rdiff -u -r1.95 -r1.96 src/sys/nfs/nfs_var.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/nfs/nfs_serv.c
diff -u src/sys/nfs/nfs_serv.c:1.182 src/sys/nfs/nfs_serv.c:1.183
--- src/sys/nfs/nfs_serv.c:1.182	Thu Sep 16 20:17:47 2021
+++ src/sys/nfs/nfs_serv.c	Wed Apr 27 17:38:52 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.182 2021/09/16 20:17:47 andvar Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.182 2021/09/16 20:17:47 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $");
 
 #include 
 #include 
@@ -422,7 +422,8 @@ nfsrv_lookup(struct nfsrv_descript *nfsd
 	nd.ni_cnd.cn_nameiop = LOOKUP;
 	nd.ni_cnd.cn_flags = LOCKLEAF;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag);
+		, NULL, NULL,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag);
 
 	if (!error && pubflag) {
 		if (nd.ni_vp->v_type == VDIR && nfs_pub.np_index != NULL &&
@@ -1447,10 +1448,8 @@ nfsrv_create(struct nfsrv_descript *nfsd
 	nd.ni_cnd.cn_nameiop = CREATE;
 	nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (dirp && v3) {
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
-	}
+		, (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error) {
 		nfsm_reply(NFSX_WCCDATA(v3));
 		nfsm_srvwcc_data(dirfor_ret, , diraft_ret, );
@@ -1689,9 +1688,8 @@ nfsrv_mknod(struct nfsrv_descript *nfsd,
 	nd.ni_cnd.cn_nameiop = CREATE;
 	nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (dirp)
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
+		, _ret, ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error) {
 		nfsm_reply(NFSX_WCCDATA(1));
 		nfsm_srvwcc_data(dirfor_ret, , diraft_ret, );
@@ -1845,14 +1843,8 @@ nfsrv_remove(struct nfsrv_descript *nfsd
 	nd.ni_cnd.cn_nameiop = DELETE;
 	nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (error == 0 && dirp && v3) {
-		if (nd.ni_dvp == nd.ni_vp)
-			vn_lock(dirp, LK_SHARED | LK_RETRY);
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
-		if (nd.ni_dvp == nd.ni_vp)
-			VOP_UNLOCK(dirp);
-	}
+		, (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (!error) {
 		vp = nd.ni_vp;
 		if (vp->v_type == VDIR) {
@@ -1944,14 +1936,8 @@ nfsrv_rename(struct nfsrv_descript *nfsd
 	fromnd.ni_cnd.cn_nameiop = DELETE;
 	fromnd.ni_cnd.cn_flags = LOCKPARENT;
 	error = nfs_namei(, , len, slp, nam, ,
-		, , lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (error == 0 && fdirp && v3) {
-		if (fromnd.ni_dvp == fromnd.ni_vp)
-			vn_lock(fdirp, LK_SHARED | LK_RETRY);
-		fdirfor_ret = VOP_GETATTR(fdirp, , cred);
-		if (fromnd.ni_dvp == fromnd.ni_vp)
-			VOP_UNLOCK(fdirp);
-	}
+		, , (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error) {
 		fromnd.ni_cnd.cn_nameiop = 0;
 		nfsm_reply(2 * NFSX_WCCDATA(v3));
@@ -2021,10 +2007,8 @@ nfsrv_rename(struct nfsrv_descript *nfsd
 	tond.ni_cnd.cn_nameiop = RENAME;
 	tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE;
 	error = nfs_namei(, , len2, slp, nam, ,
-		, , lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (tdirp && v3) {
-		tdirfor_ret = VOP_GETATTR(tdirp, , cred);
-	}
+		, , (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error) {
 		VFS_RENAMELOCK_EXIT(localfs);
 		VOP_ABORTOP(fromnd.ni_dvp, _cnd);
@@ -2218,10 +2202,8 @@ nfsrv_link(struct nfsrv_descript *nfsd, 
 	nd.ni_cnd.cn_nameiop = CREATE;
 	nd.ni_cnd.cn_flags = LOCKPARENT;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (dirp && v3) {
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
-	}
+		, (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error)
 		goto out1;
 	xp = nd.ni_vp;
@@ -2310,10 +2292,8 @@ nfsrv_symlink(struct nfsrv_descript *nfs
 	nd.ni_cnd.cn_nameiop = CREATE;
 	nd.ni_cnd.cn_flags = LOCKPARENT;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (dirp && v3) {
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
-	}
+		, (v3 ? _ret : NULL), ,
+		lwp, 

CVS commit: src/sys/nfs

2022-04-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr 27 17:38:52 UTC 2022

Modified Files:
src/sys/nfs: nfs_serv.c nfs_srvsubs.c nfs_var.h

Log Message:
As VOP_GETATTR() needs a shared lock at least move the preopattr lookup
inside nfs_namei() where we may lock the start directory without violating
the lock order.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.15 -r1.16 src/sys/nfs/nfs_srvsubs.c
cvs rdiff -u -r1.95 -r1.96 src/sys/nfs/nfs_var.h

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



CVS commit: src/sys/nfs

2022-03-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 30 10:52:59 UTC 2022

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
restructure so we abort/unlock properly on failure.


To generate a diff of this commit:
cvs rdiff -u -r1.322 -r1.323 src/sys/nfs/nfs_vnops.c

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



CVS commit: src/sys/nfs

2022-03-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 30 10:52:59 UTC 2022

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
restructure so we abort/unlock properly on failure.


To generate a diff of this commit:
cvs rdiff -u -r1.322 -r1.323 src/sys/nfs/nfs_vnops.c

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

Modified files:

Index: src/sys/nfs/nfs_vnops.c
diff -u src/sys/nfs/nfs_vnops.c:1.322 src/sys/nfs/nfs_vnops.c:1.323
--- src/sys/nfs/nfs_vnops.c:1.322	Sun Mar 27 12:24:58 2022
+++ src/sys/nfs/nfs_vnops.c	Wed Mar 30 06:52:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.322 2022/03/27 16:24:58 christos Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.323 2022/03/30 10:52:59 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.322 2022/03/27 16:24:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.323 2022/03/30 10:52:59 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -2004,21 +2004,18 @@ nfs_link(void *v)
 	struct vnode *vp = ap->a_vp;
 	struct vnode *dvp = ap->a_dvp;
 	struct componentname *cnp = ap->a_cnp;
-	int error = 0;
+	int error = 0, abrt = 1;
 
 	error = vn_lock(vp, LK_EXCLUSIVE);
-	if (error != 0) {
-		VOP_ABORTOP(dvp, cnp);
-		return error;
-	}
+	if (error != 0)
+		goto out;
 
 	error = kauth_authorize_vnode(cnp->cn_cred, KAUTH_VNODE_ADD_LINK, vp,
 	dvp, 0);
-	if (error) {
-		VOP_ABORTOP(dvp, cnp);
-		return error;
-	}
+	if (error)
+		goto out1;
 
+	abrt = 0;
 	/*
 	 * Push all writes to the server, so that the attribute cache
 	 * doesn't get "out of sync" with the server.
@@ -2032,7 +2029,11 @@ nfs_link(void *v)
 	if (error == 0) {
 		cache_purge1(dvp, cnp->cn_nameptr, cnp->cn_namelen, 0);
 	}
+out1:
 	VOP_UNLOCK(vp);
+out:
+	if (abrt)
+		VOP_ABORTOP(dvp, cnp);
 	return (error);
 }
 



CVS commit: src/sys/nfs

2022-02-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Feb 28 08:45:36 UTC 2022

Modified Files:
src/sys/nfs: nfs_clntsubs.c

Log Message:
Revert the hack from the last commit now that VOP_UNLOCK()
no longer may hold v_interlock or vmobjlock.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/nfs/nfs_clntsubs.c

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

Modified files:

Index: src/sys/nfs/nfs_clntsubs.c
diff -u src/sys/nfs/nfs_clntsubs.c:1.5 src/sys/nfs/nfs_clntsubs.c:1.6
--- src/sys/nfs/nfs_clntsubs.c:1.5	Fri Jan 14 19:19:34 2022
+++ src/sys/nfs/nfs_clntsubs.c	Mon Feb 28 08:45:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clntsubs.c,v 1.5 2022/01/14 19:19:34 christos Exp $	*/
+/*	$NetBSD: nfs_clntsubs.c,v 1.6 2022/02/28 08:45:36 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.5 2022/01/14 19:19:34 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.6 2022/02/28 08:45:36 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -360,20 +360,9 @@ nfs_delayedtruncate(struct vnode *vp)
 		np->n_flag &= ~NTRUNCDELAYED;
 		genfs_node_wrlock(vp);
 		rw_enter(vp->v_uobj.vmobjlock, RW_WRITER);
-
-		/*
-		 * This is disgusting but we can be called from VOP_UNLOCK
-		 * where the interlock is sometimes held, and we want to
-		 * make sure that it is unlocked when we call VOP_PUTPAGES
-		 * and uvm_vnp_setsize.
-		 */
-		int got = mutex_tryenter(vp->v_interlock);
-		mutex_exit(vp->v_interlock);
 		(void)VOP_PUTPAGES(vp, 0,
 		0, PGO_SYNCIO | PGO_CLEANIT | PGO_FREE | PGO_ALLPAGES);
 		uvm_vnp_setsize(vp, np->n_size);
-		if (!got)
-			mutex_enter(vp->v_interlock);
 		genfs_node_unlock(vp);
 	}
 }



CVS commit: src/sys/nfs

2022-02-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Feb 28 08:45:36 UTC 2022

Modified Files:
src/sys/nfs: nfs_clntsubs.c

Log Message:
Revert the hack from the last commit now that VOP_UNLOCK()
no longer may hold v_interlock or vmobjlock.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/nfs/nfs_clntsubs.c

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



CVS commit: src/sys/nfs

2022-01-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 14 19:19:35 UTC 2022

Modified Files:
src/sys/nfs: nfs_clntsubs.c

Log Message:
This is a temporary hack to avoid nfs crashes related to nfs_delaytruncate.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/nfs/nfs_clntsubs.c

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

Modified files:

Index: src/sys/nfs/nfs_clntsubs.c
diff -u src/sys/nfs/nfs_clntsubs.c:1.4 src/sys/nfs/nfs_clntsubs.c:1.5
--- src/sys/nfs/nfs_clntsubs.c:1.4	Sun Feb 23 10:46:41 2020
+++ src/sys/nfs/nfs_clntsubs.c	Fri Jan 14 14:19:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clntsubs.c,v 1.4 2020/02/23 15:46:41 ad Exp $	*/
+/*	$NetBSD: nfs_clntsubs.c,v 1.5 2022/01/14 19:19:34 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.4 2020/02/23 15:46:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.5 2022/01/14 19:19:34 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -360,9 +360,20 @@ nfs_delayedtruncate(struct vnode *vp)
 		np->n_flag &= ~NTRUNCDELAYED;
 		genfs_node_wrlock(vp);
 		rw_enter(vp->v_uobj.vmobjlock, RW_WRITER);
+
+		/*
+		 * This is disgusting but we can be called from VOP_UNLOCK
+		 * where the interlock is sometimes held, and we want to
+		 * make sure that it is unlocked when we call VOP_PUTPAGES
+		 * and uvm_vnp_setsize.
+		 */
+		int got = mutex_tryenter(vp->v_interlock);
+		mutex_exit(vp->v_interlock);
 		(void)VOP_PUTPAGES(vp, 0,
 		0, PGO_SYNCIO | PGO_CLEANIT | PGO_FREE | PGO_ALLPAGES);
 		uvm_vnp_setsize(vp, np->n_size);
+		if (!got)
+			mutex_enter(vp->v_interlock);
 		genfs_node_unlock(vp);
 	}
 }



CVS commit: src/sys/nfs

2022-01-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 14 19:19:35 UTC 2022

Modified Files:
src/sys/nfs: nfs_clntsubs.c

Log Message:
This is a temporary hack to avoid nfs crashes related to nfs_delaytruncate.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/nfs/nfs_clntsubs.c

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



CVS commit: src/sys/nfs

2019-09-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 10 23:19:34 UTC 2019

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
remove NCHNAMLEN optimization


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 src/sys/nfs/nfs_vnops.c

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

Modified files:

Index: src/sys/nfs/nfs_vnops.c
diff -u src/sys/nfs/nfs_vnops.c:1.311 src/sys/nfs/nfs_vnops.c:1.312
--- src/sys/nfs/nfs_vnops.c:1.311	Mon Sep  3 12:29:36 2018
+++ src/sys/nfs/nfs_vnops.c	Tue Sep 10 19:19:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.311 2018/09/03 16:29:36 riastradh Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.312 2019/09/10 23:19:34 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.311 2018/09/03 16:29:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.312 2019/09/10 23:19:34 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -2778,11 +2778,9 @@ nfs_readdirplusrpc(struct vnode *vp, str
 if (bigenough) {
 	dp->d_type =
 	   IFTODT(VTTOIF(np->n_vattr->va_type));
-	if (cnp->cn_namelen <= NCHNAMLEN) {
-	ndp->ni_vp = newvp;
-	nfs_cache_enter(ndp->ni_dvp,
-		ndp->ni_vp, cnp);
-	}
+	ndp->ni_vp = newvp;
+	nfs_cache_enter(ndp->ni_dvp,
+	ndp->ni_vp, cnp);
 }
 }
 error = 0;



CVS commit: src/sys/nfs

2019-09-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 10 23:19:34 UTC 2019

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
remove NCHNAMLEN optimization


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 src/sys/nfs/nfs_vnops.c

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



CVS commit: src/sys/nfs

2019-06-29 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Jun 29 17:42:36 UTC 2019

Modified Files:
src/sys/nfs: nfs_bootparam.c

Log Message:
Appease GCC and initialize arps_ip

Fixes build as GCC errors with maybe-uninitialized that is a false
positive.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/nfs/nfs_bootparam.c

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

Modified files:

Index: src/sys/nfs/nfs_bootparam.c
diff -u src/sys/nfs/nfs_bootparam.c:1.38 src/sys/nfs/nfs_bootparam.c:1.39
--- src/sys/nfs/nfs_bootparam.c:1.38	Thu Sep 12 18:00:18 2013
+++ src/sys/nfs/nfs_bootparam.c	Sat Jun 29 17:42:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bootparam.c,v 1.38 2013/09/12 18:00:18 drochner Exp $	*/
+/*	$NetBSD: nfs_bootparam.c,v 1.39 2019/06/29 17:42:36 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_bootparam.c,v 1.38 2013/09/12 18:00:18 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_bootparam.c,v 1.39 2019/06/29 17:42:36 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs_boot.h"
@@ -127,6 +127,7 @@ nfs_bootparam(struct nfs_diskless *nd, s
 	}
 
 	error = EADDRNOTAVAIL;
+	memset(_ip, 0, sizeof(arps_ip)); /* GCC */
 #if NARP > 0
 	if (ifp->if_type == IFT_ETHER || ifp->if_type == IFT_FDDI) {
 		/*



CVS commit: src/sys/nfs

2019-06-29 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Jun 29 17:42:36 UTC 2019

Modified Files:
src/sys/nfs: nfs_bootparam.c

Log Message:
Appease GCC and initialize arps_ip

Fixes build as GCC errors with maybe-uninitialized that is a false
positive.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/nfs/nfs_bootparam.c

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



Re: CVS commit: src/sys/nfs

2018-01-25 Thread Tom Spindler (moof)
> > Log Message:
> > Use a random opaque cookie, not kva pointer, for nfssvc(2).
> > 
> > (What were they smoking?!)

It looks like most of the code is from the 4.4-Lite merge from mycroft
circa 1994 (!!); I leave it up to the reader to determine what was
being smoked when at Berkeley.

> > I suspect most of this is actually dead code that wasn't properly
> > amputated along with the rest of the gangrene of NFSKERB a decade
> > ago, but I'm out of time to investigate further.  If someone else
> > wants to kill NFSSVC_AUTHIN/NFSSVC_AUTHINFAIL and the rest of the
> > tentacular kerberosity, be my guest.

Alas, I don't remember what moved me to kill the NFSKERB bits in
../usr.sbin/nfsd, but given that the current source still has e.g.

#ifdef NFSKERB
XXX
#else
(void)ktvin.tv_sec;
#endif

in nfs_socket.c, I think it's completely safe and worthwhile to
utterly nuke everything related to the nfs-with-kerb4 code.



Re: CVS commit: src/sys/nfs

2018-01-25 Thread Taylor R Campbell
> Date: Thu, 25 Jan 2018 19:08:16 +0100
> From: Maxime Villard 
> 
> I noticed this issue a long time ago too. While it's clear that this hack was
> utter garbage, it wasn't essentially critical since the path that leads to 
> this
> place is privileged, and basically there's everywhere the assumption that only
> the privileged NFS daemon will invoke these syscalls.

Yes.  But even root shouldn't be allowed to control arbitrary kva
pointers, unless we want to give up on the concept of securelevel>0
altogether.


Re: CVS commit: src/sys/nfs

2018-01-25 Thread Maxime Villard

Le 25/01/2018 à 18:14, Taylor R Campbell a écrit :

Module Name:src
Committed By:   riastradh
Date:   Thu Jan 25 17:14:36 UTC 2018

Modified Files:
src/sys/nfs: nfs.h nfs_syscalls.c

Log Message:
Use a random opaque cookie, not kva pointer, for nfssvc(2).

(What were they smoking?!)

I suspect most of this is actually dead code that wasn't properly
amputated along with the rest of the gangrene of NFSKERB a decade
ago, but I'm out of time to investigate further.  If someone else
wants to kill NFSSVC_AUTHIN/NFSSVC_AUTHINFAIL and the rest of the
tentacular kerberosity, be my guest.


I noticed this issue a long time ago too. While it's clear that this hack was
utter garbage, it wasn't essentially critical since the path that leads to this
place is privileged, and basically there's everywhere the assumption that only
the privileged NFS daemon will invoke these syscalls.


Re: CVS commit: src/sys/nfs

2015-11-02 Thread Paul Goyette

On Mon, 2 Nov 2015, Greg Oster wrote:


On Mon, 2 Nov 2015 09:57:43 +
"Paul Goyette"  wrote:


Module Name:src
Committed By:   pgoyette
Date:   Mon Nov  2 09:57:43 UTC 2015

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Don't forget to call nfs_fini() when we're finished.  Without this,
we leave a dangling pool nfsrvdescpl around.


Is this a candidate for pullups? (sounds like a good fix to me! :) )


Considering that this actually fixes (at least) one of my three nasty
module-related issues (see thread on current-users), I think it is an
excellent candidate for pull-up.



+--+--+-+
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:   |
| (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com|
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org  |
+--+--+-+


Re: CVS commit: src/sys/nfs

2013-12-14 Thread John Nemeth
On Dec 14, 11:19am, Christos Zoulas wrote:
} Subject: CVS commit: src/sys/nfs
} This is a multi-part message in MIME format.
} 
} --_--=_138703796849810
} Content-Disposition: inline
} Content-Transfer-Encoding: 8bit
} Content-Type: text/plain; charset=US-ASCII
} 
} Module Name:  src
} Committed By: christos
} Date: Sat Dec 14 16:19:28 UTC 2013
} 
} Modified Files:
}   src/sys/nfs: nfs_export.c nfs_serv.c nfs_var.h
} 
} Log Message:
} don't allow the nfs server module to unload if it has exported filesystems.
} 
} 
} To generate a diff of this commit:
} cvs rdiff -u -r1.57 -r1.58 src/sys/nfs/nfs_export.c
} cvs rdiff -u -r1.166 -r1.167 src/sys/nfs/nfs_serv.c
} cvs rdiff -u -r1.90 -r1.91 src/sys/nfs/nfs_var.h
} 
} Please note that diffs are not public domain; they are subject to the
} copyright notices on the relevant files.
} 
} 
} --_--=_138703796849810
} Content-Disposition: inline
} Content-Transfer-Encoding: 8bit
} Content-Type: text/x-diff; charset=us-ascii
} 
} Modified files:
} 
} Index: src/sys/nfs/nfs_export.c
} diff -u src/sys/nfs/nfs_export.c:1.57 src/sys/nfs/nfs_export.c:1.58
} --- src/sys/nfs/nfs_export.c:1.57 Sat Nov 23 09:20:46 2013
} +++ src/sys/nfs/nfs_export.c  Sat Dec 14 11:19:28 2013
} @@ -1,4 +1,4 @@
} -/*   $NetBSD: nfs_export.c,v 1.57 2013/11/23 14:20:46 christos Exp $ */
} +/*   $NetBSD: nfs_export.c,v 1.58 2013/12/14 16:19:28 christos Exp $ */
}  
}  /*-
}   * Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc.
} @@ -77,7 +77,7 @@
}   */
}  
}  #include sys/cdefs.h
} -__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.57 2013/11/23 14:20:46 christos 
Exp $);
} +__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.58 2013/12/14 16:19:28 christos 
Exp $);
}  
}  #include sys/param.h
}  #include sys/systm.h
} @@ -877,3 +877,10 @@ netexport_wrunlock(void)
}  
}   rw_exit(netexport_lock);
}  }
} +
} +bool
} +netexport_hasexports(void)
} +{
} + 
} + return nfs_pub.np_valid || !TAILQ_EMPTY(netexport_list);
} +}
} 
} Index: src/sys/nfs/nfs_serv.c
} diff -u src/sys/nfs/nfs_serv.c:1.166 src/sys/nfs/nfs_serv.c:1.167
} --- src/sys/nfs/nfs_serv.c:1.166  Sat Sep 14 18:29:08 2013
} +++ src/sys/nfs/nfs_serv.cSat Dec 14 11:19:28 2013
} @@ -1,4 +1,4 @@
} -/*   $NetBSD: nfs_serv.c,v 1.166 2013/09/14 22:29:08 martin Exp $*/
} +/*   $NetBSD: nfs_serv.c,v 1.167 2013/12/14 16:19:28 christos Exp $  */
}  
}  /*
}   * Copyright (c) 1989, 1993
} @@ -55,7 +55,7 @@
}   */
}  
}  #include sys/cdefs.h
} -__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.166 2013/09/14 22:29:08 martin 
Exp $);
} +__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.167 2013/12/14 16:19:28 christos 
Exp $);
}  
}  #include sys/param.h
}  #include sys/systm.h
} @@ -125,6 +125,8 @@ nfsserver_modcmd(modcmd_t cmd, void *arg
}   nfs_timer_srvinit(nfsrv_timer);
}   return 0;
}   case MODULE_CMD_FINI:
} + if (netexport_hasexports())
} + return EBUSY;

 I thought the idea was only to disallow autounload when there were
exports?  This change will also disallow manual unloading.

}   error = syscall_disestablish(NULL, nfsserver_syscalls);
}   if (error != 0) {
}   return error;
} 
} Index: src/sys/nfs/nfs_var.h
} diff -u src/sys/nfs/nfs_var.h:1.90 src/sys/nfs/nfs_var.h:1.91
} --- src/sys/nfs/nfs_var.h:1.90Tue Mar  2 18:19:09 2010
} +++ src/sys/nfs/nfs_var.h Sat Dec 14 11:19:28 2013
} @@ -1,4 +1,4 @@
} -/*   $NetBSD: nfs_var.h,v 1.90 2010/03/02 23:19:09 pooka Exp $   */
} +/*   $NetBSD: nfs_var.h,v 1.91 2013/12/14 16:19:28 christos Exp $*/
}  
}  /*-
}   * Copyright (c) 1996 The NetBSD Foundation, Inc.
} @@ -349,4 +349,5 @@ void netexport_rdlock(void);
}  void netexport_rdunlock(void);
}  void netexport_init(void);
}  void netexport_fini(void);
} +bool netexport_hasexports(void);
}  #endif /* _KERNEL */
} 
} 
} --_--=_138703796849810--
} 
}-- End of excerpt from Christos Zoulas


Re: CVS commit: src/sys/nfs

2013-12-14 Thread Paul Goyette

On Sat, 14 Dec 2013, John Nemeth wrote:


}   case MODULE_CMD_FINI:
} + if (netexport_hasexports())
} + return EBUSY;

I thought the idea was only to disallow autounload when there were
exports?  This change will also disallow manual unloading.


It was my original intent to affect only the auto-unload.  It really 
isn't necessary to prevent the manual unload, since we forcibly clear 
the export list anyway by calling netexport_fini() (right after we 
disestablish the syscall).




-
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:   |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com|
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |  | pgoyette at netbsd.org  |
-


Re: CVS commit: src/sys/nfs

2011-11-15 Thread J. Hannken-Illjes
On Nov 15, 2011, at 4:08 AM, YAMAMOTO Takashi wrote:

 hi,
 
 Module Name: src
 Committed By:hannken
 Date:Sun Oct 30 12:00:28 UTC 2011
 
 Modified Files:
  src/sys/nfs: nfs_serv.c
 
 Log Message:
 VOP_GETATTR() needs a shared lock at least.
 
 this seems trying to lock the directory while holding its child locked.
 ie. wrong locking order

Seems I overlooked one case, the change on top of nfsrv_lookup().  All other
changes should use the right locking order.

--
Juergen Hannken-Illjes - hann...@eis.cs.tu-bs.de - TU Braunschweig (Germany)



Re: CVS commit: src/sys/nfs

2011-11-14 Thread YAMAMOTO Takashi
hi,

 Module Name:  src
 Committed By: hannken
 Date: Sun Oct 30 12:00:28 UTC 2011
 
 Modified Files:
   src/sys/nfs: nfs_serv.c
 
 Log Message:
 VOP_GETATTR() needs a shared lock at least.

this seems trying to lock the directory while holding its child locked.
ie. wrong locking order

YAMAMOTO Takashi

 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.160 -r1.161 src/sys/nfs/nfs_serv.c
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


Re: CVS commit: src/sys/nfs

2011-03-23 Thread Erik Fair
Pullup candidate?

On Mar 23, 2011, at 10:42, Thor Lancelot Simon wrote:

 Module Name:  src
 Committed By: tls
 Date: Wed Mar 23 17:42:11 UTC 2011
 
 Modified Files:
   src/sys/nfs: nfs_socket.c
 
 Log Message:
 As suggested by matt@: change socket buffer reservations for NFS send/receive
 to 3 times max RPC size rather than 2 times.  Avoids nasty TCP stalls observed
 at Panix.  Will require increase to sbmax via sysctl for those running really
 huge NFS rsize/wsize (64K).
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.188 -r1.189 src/sys/nfs/nfs_socket.c
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.
 



CVS commit: src/sys/nfs

2010-03-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Mar  2 23:19:09 UTC 2010

Modified Files:
src/sys/nfs: files.nfs nfs.h nfs_bootparam.c nfs_socket.c nfs_subs.c
nfs_var.h nfs_vfsops.c
Added Files:
src/sys/nfs: nfs_clntsocket.c nfs_clntsubs.c

Log Message:
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not.  The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/nfs/files.nfs
cvs rdiff -u -r1.71 -r1.72 src/sys/nfs/nfs.h
cvs rdiff -u -r1.35 -r1.36 src/sys/nfs/nfs_bootparam.c
cvs rdiff -u -r0 -r1.1 src/sys/nfs/nfs_clntsocket.c \
src/sys/nfs/nfs_clntsubs.c
cvs rdiff -u -r1.186 -r1.187 src/sys/nfs/nfs_socket.c
cvs rdiff -u -r1.218 -r1.219 src/sys/nfs/nfs_subs.c
cvs rdiff -u -r1.89 -r1.90 src/sys/nfs/nfs_var.h
cvs rdiff -u -r1.210 -r1.211 src/sys/nfs/nfs_vfsops.c

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



CVS commit: src/sys/nfs

2010-03-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Mar  2 23:49:11 UTC 2010

Modified Files:
src/sys/nfs: files.nfs

Log Message:
don't create unused fs_nfs.h


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/nfs/files.nfs

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

Modified files:

Index: src/sys/nfs/files.nfs
diff -u src/sys/nfs/files.nfs:1.12 src/sys/nfs/files.nfs:1.13
--- src/sys/nfs/files.nfs:1.12	Tue Mar  2 23:19:09 2010
+++ src/sys/nfs/files.nfs	Tue Mar  2 23:49:11 2010
@@ -1,6 +1,6 @@
-#	$NetBSD: files.nfs,v 1.12 2010/03/02 23:19:09 pooka Exp $
+#	$NetBSD: files.nfs,v 1.13 2010/03/02 23:49:11 pooka Exp $
 
-deffs	fs_nfs.h		NFS
+deffsNFS
 
 defflag opt_nfs_boot.h		NFS_BOOT_BOOTP NFS_BOOT_BOOTPARAM NFS_BOOT_DHCP
 NFS_BOOT_GATEWAY NFS_BOOT_TCP



CVS commit: src/sys/nfs

2010-03-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Mar  2 23:49:11 UTC 2010

Modified Files:
src/sys/nfs: files.nfs

Log Message:
don't create unused fs_nfs.h


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/nfs/files.nfs

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



CVS commit: src/sys/nfs

2010-01-19 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Tue Jan 19 13:29:40 UTC 2010

Modified Files:
src/sys/nfs: nfs.h

Log Message:
remove unused r_timer member.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/nfs/nfs.h

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



CVS commit: src/sys/nfs

2009-12-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 31 19:30:45 UTC 2009

Modified Files:
src/sys/nfs: files.nfs

Log Message:
nuidhash_max is needed by sys_nfssvc


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/nfs/files.nfs

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



CVS commit: src/sys/nfs

2009-12-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 31 19:31:31 UTC 2009

Modified Files:
src/sys/nfs: nfs_socket.c

Log Message:
appease gcc.


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/sys/nfs/nfs_socket.c

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



CVS commit: src/sys/nfs

2009-12-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 31 19:38:16 UTC 2009

Modified Files:
src/sys/nfs: files.nfs nfs_iod.c nfs_syscalls.c

Log Message:
handle the nuidhash_max lossage differently


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/nfs/files.nfs
cvs rdiff -u -r1.3 -r1.4 src/sys/nfs/nfs_iod.c
cvs rdiff -u -r1.151 -r1.152 src/sys/nfs/nfs_syscalls.c

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



Re: CVS commit: src/sys/nfs

2009-09-03 Thread Robert Swindells

Thor Lancelot Simon wrote:
Module Name:src
Committed By:   tls
Date:   Thu Sep  3 20:59:13 UTC 2009

Modified Files:
src/sys/nfs: nfs_srvsocket.c

Log Message:
Missed this file in previous commit, accidentally checked in fix to local
repository copy!  Sorry about that, folks.

I think we also need the following, not tested:

Index: smb_trantcp.c
===
RCS file: /cvsroot/src/sys/netsmb/smb_trantcp.c,v
retrieving revision 1.42
diff -u -r1.42 smb_trantcp.c
--- smb_trantcp.c   29 Mar 2009 19:21:20 -  1.42
+++ smb_trantcp.c   3 Sep 2009 23:32:25 -
@@ -127,7 +127,7 @@
 }
 
 static void
-nb_upcall(struct socket *so, void *arg, int waitflag)
+nb_upcall(struct socket *so, void *arg, int events, int waitflag)
 {
struct nbpcb *nbp = (void *)arg;
 


Re: CVS commit: src/sys/nfs

2009-05-10 Thread YAMAMOTO Takashi
hi,

 On Sun, May 10, 2009 at 05:18:26AM +, YAMAMOTO Takashi wrote:
   Module Name:   src
   Committed By:  yamt
   Date:  Sun May 10 05:18:26 UTC 2009
   
   Modified Files:
  src/sys/nfs: nfs_vnops.c
   
   Log Message:
   nfs_lookup: vn_lock the vnode returned by cache_lookup_raw
   before feeding it to VOP_GETATTR.  it's necessary because the vnode might
   be being cleaned by getcleanvnode.
   
   it's an instance of more general races between vnode reclaim and
   unlocked VOPs.  however, this one happens somewhat often because it can be
   triggered by getnewvnode rather than revoke.
 
 This seems a bit odd; cache_lookup_raw returns a reference to the
 vnode, so the vnode shouldn't *be* getting reclaimed after that.
 
 Or so I'd think. (?)

there is a race.  see PR/41374.
besides that, a vnode reference does not prevent revoke(2).

YAMAMOTO Takashi

 
 -- 
 David A. Holland
 dholl...@netbsd.org


Re: CVS commit: src/sys/nfs

2009-05-06 Thread David Holland
On Wed, May 06, 2009 at 07:35:32AM +0200, Christoph Egger wrote:
   This is wrong; the values are of type size_t and should be printed
   with %zu.
  
  Fixed. gcc warning confused me saying the expected type was
  'unsigned int'.

Well yes, size_t is unsigned int on i386. Gotta read the source...

Thanks.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys/nfs

2009-05-05 Thread David Holland
On Tue, May 05, 2009 at 12:48:31PM +, Christoph Egger wrote:
  Module Name: src
  Committed By:cegger
  Date:Tue May  5 12:48:31 UTC 2009
  
  Modified Files:
   src/sys/nfs: nfs_bootdhcp.c
  
  Log Message:
  buildfix: use %d for BOOTP_SIZE_(MIN,MAX).
  Makes i386 ALL kernel build again.

This is wrong; the values are of type size_t and should be printed
with %zu.

-- 
David A. Holland
dholl...@netbsd.org