aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2019-09-27 16:22:28 +0000
committerAndrew Turner <andrew@FreeBSD.org>2019-09-27 16:22:28 +0000
commit50bb04b7505796a69687946c1712a69043ec1d7d (patch)
treeb21ce7cc3b0f59cb441dcf3d00db74f7d72fc5ef /sys
parent4470d73996490701dd68db61ee91c760ba39841c (diff)
downloadsrc-50bb04b7505796a69687946c1712a69043ec1d7d.tar.gz
src-50bb04b7505796a69687946c1712a69043ec1d7d.zip
Check the vfs option length is valid before accessing through
When a VFS option passed to nmount is present but NULL the kernel will place an empty option in its internal list. This will have a NULL pointer and a length of 0. When we come to read one of these the kernel will try to load from the last address of virtual memory. This is normally invalid so will fault resulting in a kernel panic. Fix this by checking if the length is valid before dereferencing. MFC after: 3 days Sponsored by: DARPA, AFRL
Notes
Notes: svn path=/head/; revision=352796
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_mount.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 633fc27a6c98..258b40a69859 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -646,7 +646,7 @@ vfs_donmount(struct thread *td, uint64_t fsflags, struct uio *fsoptions)
*/
fstypelen = 0;
error = vfs_getopt(optlist, "fstype", (void **)&fstype, &fstypelen);
- if (error || fstype[fstypelen - 1] != '\0') {
+ if (error || fstypelen <= 0 || fstype[fstypelen - 1] != '\0') {
error = EINVAL;
if (errmsg != NULL)
strncpy(errmsg, "Invalid fstype", errmsg_len);
@@ -654,7 +654,7 @@ vfs_donmount(struct thread *td, uint64_t fsflags, struct uio *fsoptions)
}
fspathlen = 0;
error = vfs_getopt(optlist, "fspath", (void **)&fspath, &fspathlen);
- if (error || fspath[fspathlen - 1] != '\0') {
+ if (error || fspathlen <= 0 || fspath[fspathlen - 1] != '\0') {
error = EINVAL;
if (errmsg != NULL)
strncpy(errmsg, "Invalid fspath", errmsg_len);