Add a sanity check for the existence of an "addr" option
to both NFS clients. This avoids the crash reported by Sergey Kandaurov (pluknet@gmail.com) to the freebsd-fs@ list with subject "[old nfsclient] different nmount() args passed from mount vs mount_nfs" dated May 17, 2011. Tested by: pluknet at gmail.com (old nfs client) MFC after: 2 weeks
This commit is contained in:
parent
0bd47e8362
commit
b70cddba44
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=222075
@ -1079,15 +1079,21 @@ nfs_mount(struct mount *mp)
|
||||
dirpath[0] = '\0';
|
||||
dirlen = strlen(dirpath);
|
||||
|
||||
if (has_nfs_args_opt == 0 && vfs_getopt(mp->mnt_optnew, "addr",
|
||||
(void **)&args.addr, &args.addrlen) == 0) {
|
||||
if (args.addrlen > SOCK_MAXADDRLEN) {
|
||||
error = ENAMETOOLONG;
|
||||
if (has_nfs_args_opt == 0) {
|
||||
if (vfs_getopt(mp->mnt_optnew, "addr",
|
||||
(void **)&args.addr, &args.addrlen) == 0) {
|
||||
if (args.addrlen > SOCK_MAXADDRLEN) {
|
||||
error = ENAMETOOLONG;
|
||||
goto out;
|
||||
}
|
||||
nam = malloc(args.addrlen, M_SONAME, M_WAITOK);
|
||||
bcopy(args.addr, nam, args.addrlen);
|
||||
nam->sa_len = args.addrlen;
|
||||
} else {
|
||||
vfs_mount_error(mp, "No server address");
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
nam = malloc(args.addrlen, M_SONAME, M_WAITOK);
|
||||
bcopy(args.addr, nam, args.addrlen);
|
||||
nam->sa_len = args.addrlen;
|
||||
}
|
||||
|
||||
args.fh = nfh;
|
||||
|
@ -1149,6 +1149,10 @@ nfs_mount(struct mount *mp)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
} else if (has_addr_opt == 0) {
|
||||
vfs_mount_error(mp, "No server address");
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
error = mountnfs(&args, mp, nam, args.hostname, &vp,
|
||||
curthread->td_ucred, negnametimeo);
|
||||
|
Loading…
Reference in New Issue
Block a user