Skip to content

Commit

Permalink
NFS client: fix interop with macOS 14 servers.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
schmonz committed Dec 10, 2023
1 parent 35fd37d commit fee42fd
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions sys/nfs/nfs_vnops.c
@@ -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
Expand Down Expand Up @@ -39,7 +39,7 @@
*/

#include <sys/cdefs.h>
__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"
Expand Down Expand Up @@ -2422,8 +2422,13 @@ nfs_readdirrpc(struct vnode *vp, struct uio *uiop, kauth_cred_t cred)
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
{
Expand Down Expand Up @@ -2632,8 +2637,13 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, kauth_cred_t cred)
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);
Expand Down

0 comments on commit fee42fd

Please sign in to comment.