git: 8d7d3c6963f8 - stable/13 - nfscl: Add NFSD_CURVNET macros to nfsclient syscall
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 17 May 2023 22:20:17 UTC
The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=8d7d3c6963f8d504e0d02353bacce767a907ca5d commit 8d7d3c6963f8d504e0d02353bacce767a907ca5d Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2023-02-21 00:40:07 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2023-05-17 22:19:19 +0000 nfscl: Add NFSD_CURVNET macros to nfsclient syscall Although the nfsclient syscall is used for client side, it does set up server side krpc for callbacks. As such, it needs to have the vnet set. This patch does this. Without this patch, the system would crash when the nfscbd(8) daemon was killed. (cherry picked from commit 357492c99597d13bc966441f30bb44f6ef659f08) --- sys/fs/nfsclient/nfs_clport.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c index 4d8599c18363..1d2617b2bb9b 100644 --- a/sys/fs/nfsclient/nfs_clport.c +++ b/sys/fs/nfsclient/nfs_clport.c @@ -1276,10 +1276,11 @@ nfssvc_nfscl(struct thread *td, struct nfssvc_args *uap) struct mount *mp; struct nfsmount *nmp; + NFSD_CURVNET_SET(NFSD_TD_TO_VNET(td)); if (uap->flag & NFSSVC_CBADDSOCK) { error = copyin(uap->argp, (caddr_t)&nfscbdarg, sizeof(nfscbdarg)); if (error) - return (error); + goto out; /* * Since we don't know what rights might be required, * pretend that we need them all. It is better to be too @@ -1288,10 +1289,11 @@ nfssvc_nfscl(struct thread *td, struct nfssvc_args *uap) error = fget(td, nfscbdarg.sock, cap_rights_init_one(&rights, CAP_SOCK_CLIENT), &fp); if (error) - return (error); + goto out; if (fp->f_type != DTYPE_SOCKET) { fdrop(fp, td); - return (EPERM); + error = EPERM; + goto out; } error = nfscbd_addsock(fp); fdrop(fp, td); @@ -1300,12 +1302,14 @@ nfssvc_nfscl(struct thread *td, struct nfssvc_args *uap) nfscl_enablecallb = 1; } } else if (uap->flag & NFSSVC_NFSCBD) { - if (uap->argp == NULL) - return (EINVAL); + if (uap->argp == NULL) { + error = EINVAL; + goto out; + } error = copyin(uap->argp, (caddr_t)&nfscbdarg2, sizeof(nfscbdarg2)); if (error) - return (error); + goto out; error = nfscbd_nfsd(td, &nfscbdarg2); } else if (uap->flag & NFSSVC_DUMPMNTOPTS) { error = copyin(uap->argp, &dumpmntopts, sizeof(dumpmntopts)); @@ -1391,6 +1395,8 @@ nfssvc_nfscl(struct thread *td, struct nfssvc_args *uap) } else { error = EINVAL; } +out: + NFSD_CURVNET_RESTORE(); return (error); }