Date: Fri, 23 Nov 2018 21:08:11 +0000 (UTC) From: Ed Maste <emaste@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r340855 - in releng/12.0/sys/fs: nfs nfsserver Message-ID: <201811232108.wANL8BhU070318@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: emaste Date: Fri Nov 23 21:08:11 2018 New Revision: 340855 URL: https://svnweb.freebsd.org/changeset/base/340855 Log: MFS12 r340849, r340850, r340851: MFC r340661 (rmacklem): r304026 added code that started statistics gathering for an operation before the operation number (the variable called "op") was sanity checked. This patch moves the code down to below the range sanity check for "op". MFC r340662 (rmacklem): nfsm_advance() would panic() when the offs argument was negative. The code assumed that this would indicate a corrupted mbuf chain, but it could simply be caused by bogus RPC message data. This patch replaces the panic() with a printf() plus error return. MFC r340663 (rmacklem): Improve sanity checking for the dircount hint argument to NFSv3's ReaddirPlus and NFSv4's Readdir operations. The code checked for a zero argument, but did not check for a very large value. This patch clips dircount at the server's maximum data size. Approved by: re (kib) Modified: releng/12.0/sys/fs/nfs/nfs_commonsubs.c releng/12.0/sys/fs/nfsserver/nfs_nfsdport.c releng/12.0/sys/fs/nfsserver/nfs_nfsdsocket.c Directory Properties: releng/12.0/ (props changed) Modified: releng/12.0/sys/fs/nfs/nfs_commonsubs.c ============================================================================== --- releng/12.0/sys/fs/nfs/nfs_commonsubs.c Fri Nov 23 20:41:54 2018 (r340854) +++ releng/12.0/sys/fs/nfs/nfs_commonsubs.c Fri Nov 23 21:08:11 2018 (r340855) @@ -725,10 +725,14 @@ nfsm_advance(struct nfsrv_descript *nd, int offs, int if (offs == 0) goto out; /* - * A negative offs should be considered a serious problem. + * A negative offs might indicate a corrupted mbuf chain and, + * as such, a printf is logged. */ - if (offs < 0) - panic("nfsrv_advance"); + if (offs < 0) { + printf("nfsrv_advance: negative offs\n"); + error = EBADRPC; + goto out; + } /* * If left == -1, calculate it here. Modified: releng/12.0/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- releng/12.0/sys/fs/nfsserver/nfs_nfsdport.c Fri Nov 23 20:41:54 2018 (r340854) +++ releng/12.0/sys/fs/nfsserver/nfs_nfsdport.c Fri Nov 23 21:08:11 2018 (r340855) @@ -2107,9 +2107,15 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdg * cookie) should be in the reply. At least one client "hints" 0, * so I set it to cnt for that case. I also round it up to the * next multiple of DIRBLKSIZ. + * Since the size of a Readdirplus directory entry reply will always + * be greater than a directory entry returned by VOP_READDIR(), it + * does not make sense to read more than NFS_SRVMAXDATA() via + * VOP_READDIR(). */ if (siz <= 0) siz = cnt; + else if (siz > NFS_SRVMAXDATA(nd)) + siz = NFS_SRVMAXDATA(nd); siz = ((siz + DIRBLKSIZ - 1) & ~(DIRBLKSIZ - 1)); if (nd->nd_flag & ND_NFSV4) { Modified: releng/12.0/sys/fs/nfsserver/nfs_nfsdsocket.c ============================================================================== --- releng/12.0/sys/fs/nfsserver/nfs_nfsdsocket.c Fri Nov 23 20:41:54 2018 (r340854) +++ releng/12.0/sys/fs/nfsserver/nfs_nfsdsocket.c Fri Nov 23 21:08:11 2018 (r340855) @@ -766,11 +766,6 @@ nfsrvd_compound(struct nfsrv_descript *nd, int isdgram *repp = *tl; op = fxdr_unsigned(int, *tl); NFSD_DEBUG(4, "op=%d\n", op); - - binuptime(&start_time); - nfsrvd_statstart(op, &start_time); - statsinprog = 1; - if (op < NFSV4OP_ACCESS || (op >= NFSV4OP_NOPS && (nd->nd_flag & ND_NFSV41) == 0) || (op >= NFSV41_NOPS && (nd->nd_flag & ND_NFSV41) != 0)) { @@ -782,6 +777,11 @@ nfsrvd_compound(struct nfsrv_descript *nd, int isdgram } else { repp++; } + + binuptime(&start_time); + nfsrvd_statstart(op, &start_time); + statsinprog = 1; + if (i == 0) op0 = op; if (i == numops - 1)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811232108.wANL8BhU070318>