git: d5335bdee715 - stable/15 - nfs_clvfsops.c: Allow long directory mount paths
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 23 Nov 2025 13:26:07 UTC
The branch stable/15 has been updated by rmacklem:
URL: https://cgit.FreeBSD.org/src/commit/?id=d5335bdee7157af3897d0a49834c3493e0d03681
commit d5335bdee7157af3897d0a49834c3493e0d03681
Author: Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2025-10-29 21:41:12 +0000
Commit: Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2025-11-23 13:24:13 +0000
nfs_clvfsops.c: Allow long directory mount paths
Without this patch, the NFS client code for mounts has
an arbitrary 100 character limit for the directory path
being mounted on the server.
Someone reported this quite a while ago, but I cannot
find the email or bugzilla PR.
This patch fixes the problem by increasing the directory
path length limit to MNAMELEN, allocated via malloc() to
avoid using too much stack.
(cherry picked from commit 8d5a88ac95b23b0a8c4943be0aef1f93e3902bfb)
---
sys/fs/nfsclient/nfs_clvfsops.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c
index 5ea7eab07632..212c88f28930 100644
--- a/sys/fs/nfsclient/nfs_clvfsops.c
+++ b/sys/fs/nfsclient/nfs_clvfsops.c
@@ -927,7 +927,7 @@ nfs_mount(struct mount *mp)
struct vnode *vp;
struct thread *td;
char *hst;
- u_char nfh[NFSX_FHMAX], krbname[100], dirpath[100], srvkrbname[100];
+ u_char nfh[NFSX_FHMAX], krbname[100], *dirpath, srvkrbname[100];
char *cp, *opt, *name, *secname, *tlscertname;
int nametimeo = NFS_DEFAULT_NAMETIMEO;
int negnametimeo = NFS_DEFAULT_NEGNAMETIMEO;
@@ -943,6 +943,7 @@ nfs_mount(struct mount *mp)
newflag = 0;
tlscertname = NULL;
hst = malloc(MNAMELEN, M_TEMP, M_WAITOK);
+ dirpath = malloc(MNAMELEN, M_TEMP, M_WAITOK);
if (vfs_filteropt(mp->mnt_optnew, nfs_opts)) {
error = EINVAL;
goto out;
@@ -1329,7 +1330,7 @@ nfs_mount(struct mount *mp)
goto out;
} else if (nfs_mount_parse_from(mp->mnt_optnew,
&args.hostname, (struct sockaddr_in **)&nam, dirpath,
- sizeof(dirpath), &dirlen) == 0) {
+ MNAMELEN, &dirlen) == 0) {
has_nfs_from_opt = 1;
bcopy(args.hostname, hst, MNAMELEN);
hst[MNAMELEN - 1] = '\0';
@@ -1387,7 +1388,7 @@ nfs_mount(struct mount *mp)
if (has_nfs_from_opt == 0) {
if (vfs_getopt(mp->mnt_optnew,
"dirpath", (void **)&name, NULL) == 0)
- strlcpy(dirpath, name, sizeof (dirpath));
+ strlcpy(dirpath, name, MNAMELEN);
else
dirpath[0] = '\0';
dirlen = strlen(dirpath);
@@ -1472,6 +1473,7 @@ out:
MNT_IUNLOCK(mp);
}
free(hst, M_TEMP);
+ free(dirpath, M_TEMP);
return (error);
}