From owner-svn-src-all@FreeBSD.ORG Fri Apr 23 00:12:23 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE08E106564A; Fri, 23 Apr 2010 00:12:23 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BB6F98FC12; Fri, 23 Apr 2010 00:12:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3N0CNKx033897; Fri, 23 Apr 2010 00:12:23 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3N0CNiZ033891; Fri, 23 Apr 2010 00:12:23 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201004230012.o3N0CNiZ033891@svn.freebsd.org> From: Rick Macklem Date: Fri, 23 Apr 2010 00:12:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r207085 - in stable/8/sys/fs: nfs nfsclient X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Apr 2010 00:12:24 -0000 Author: rmacklem Date: Fri Apr 23 00:12:23 2010 New Revision: 207085 URL: http://svn.freebsd.org/changeset/base/207085 Log: MFC: r206688 The experimental NFS client was not filling in recovery credentials for opens done locally in the client when a delegation for the file was held. This could cause the client to crash in crsetgroups() when recovering from a server crash/reboot. This patch fills in the recovery credentials for this case, in order to avoid the client crash. Also, add KASSERT()s to the credential copy functions, to catch any other cases where the credentials aren't filled in correctly. Modified: stable/8/sys/fs/nfs/nfs_commonport.c stable/8/sys/fs/nfs/nfsclstate.h stable/8/sys/fs/nfsclient/nfs_clport.c stable/8/sys/fs/nfsclient/nfs_clrpcops.c stable/8/sys/fs/nfsclient/nfs_clstate.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/geom/sched/ (props changed) Modified: stable/8/sys/fs/nfs/nfs_commonport.c ============================================================================== --- stable/8/sys/fs/nfs/nfs_commonport.c Fri Apr 23 00:11:38 2010 (r207084) +++ stable/8/sys/fs/nfs/nfs_commonport.c Fri Apr 23 00:12:23 2010 (r207085) @@ -225,6 +225,8 @@ void newnfs_copycred(struct nfscred *nfscr, struct ucred *cr) { + KASSERT(nfscr->nfsc_ngroups >= 0, + ("newnfs_copycred: negative nfsc_ngroups")); cr->cr_uid = nfscr->nfsc_uid; crsetgroups(cr, nfscr->nfsc_ngroups, nfscr->nfsc_groups); } Modified: stable/8/sys/fs/nfs/nfsclstate.h ============================================================================== --- stable/8/sys/fs/nfs/nfsclstate.h Fri Apr 23 00:11:38 2010 (r207084) +++ stable/8/sys/fs/nfs/nfsclstate.h Fri Apr 23 00:12:23 2010 (r207085) @@ -140,6 +140,7 @@ struct nfsclopen { #define NFSCLOPEN_OK 0 #define NFSCLOPEN_DOOPEN 1 #define NFSCLOPEN_DOOPENDOWNGRADE 2 +#define NFSCLOPEN_SETCRED 3 struct nfscllockowner { LIST_ENTRY(nfscllockowner) nfsl_list; Modified: stable/8/sys/fs/nfsclient/nfs_clport.c ============================================================================== --- stable/8/sys/fs/nfsclient/nfs_clport.c Fri Apr 23 00:11:38 2010 (r207084) +++ stable/8/sys/fs/nfsclient/nfs_clport.c Fri Apr 23 00:12:23 2010 (r207085) @@ -978,6 +978,8 @@ newnfs_copyincred(struct ucred *cr, stru { int i; + KASSERT(cr->cr_ngroups >= 0, + ("newnfs_copyincred: negative cr_ngroups")); nfscr->nfsc_uid = cr->cr_uid; nfscr->nfsc_ngroups = MIN(cr->cr_ngroups, NFS_MAXGRPS + 1); for (i = 0; i < nfscr->nfsc_ngroups; i++) Modified: stable/8/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- stable/8/sys/fs/nfsclient/nfs_clrpcops.c Fri Apr 23 00:11:38 2010 (r207084) +++ stable/8/sys/fs/nfsclient/nfs_clrpcops.c Fri Apr 23 00:12:23 2010 (r207085) @@ -280,7 +280,13 @@ else printf(" fhl=0\n"); error = EIO; } newnfs_copyincred(cred, &op->nfso_cred); - } + } else if (ret == NFSCLOPEN_SETCRED) + /* + * This is a new local open on a delegation. It needs + * to have credentials so that an open can be done + * against the server during recovery. + */ + newnfs_copyincred(cred, &op->nfso_cred); /* * nfso_opencnt is the count of how many VOP_OPEN()s have Modified: stable/8/sys/fs/nfsclient/nfs_clstate.c ============================================================================== --- stable/8/sys/fs/nfsclient/nfs_clstate.c Fri Apr 23 00:11:38 2010 (r207084) +++ stable/8/sys/fs/nfsclient/nfs_clstate.c Fri Apr 23 00:12:23 2010 (r207085) @@ -274,8 +274,13 @@ nfscl_open(vnode_t vp, u_int8_t *nfhp, i *owpp = owp; if (opp != NULL) *opp = op; - if (retp != NULL) - *retp = NFSCLOPEN_OK; + if (retp != NULL) { + if (nfhp != NULL && dp != NULL && nop == NULL) + /* new local open on delegation */ + *retp = NFSCLOPEN_SETCRED; + else + *retp = NFSCLOPEN_OK; + } /* * Now, check the mode on the open and return the appropriate