diff options
author | adrian <adrian@FreeBSD.org> | 2001-03-01 21:00:17 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2001-03-01 21:00:17 +0000 |
commit | 401895533496c6f7943c0cadf487c2cfa8f852ac (patch) | |
tree | 19b63a29b1f18d2efdee5765c5bffd371838dd1e /sys/gnu | |
parent | 845eeac4fc47466824d871b49fc54af4c3812e09 (diff) | |
download | FreeBSD-src-401895533496c6f7943c0cadf487c2cfa8f852ac.zip FreeBSD-src-401895533496c6f7943c0cadf487c2cfa8f852ac.tar.gz |
Reviewed by: jlemon
An initial tidyup of the mount() syscall and VFS mount code.
This code replaces the earlier work done by jlemon in an attempt to
make linux_mount() work.
* the guts of the mount work has been moved into vfs_mount().
* move `type', `path' and `flags' from being userland variables into being
kernel variables in vfs_mount(). `data' remains a pointer into
userspace.
* Attempt to verify the `type' and `path' strings passed to vfs_mount()
aren't too long.
* rework mount() and linux_mount() to take the userland parameters
(besides data, as mentioned) and pass kernel variables to vfs_mount().
(linux_mount() already did this, I've just tidied it up a little more.)
* remove the copyin*() stuff for `path'. `data' still requires copyin*()
since its a pointer into userland.
* set `mount->mnt_statf_mntonname' in vfs_mount() rather than in each
filesystem. This variable is generally initialised with `path', and
each filesystem can override it if they want to.
* NOTE: f_mntonname is intiailised with "/" in the case of a root mount.
Diffstat (limited to 'sys/gnu')
-rw-r--r-- | sys/gnu/ext2fs/ext2_vfsops.c | 16 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_vfsops.c | 16 |
2 files changed, 22 insertions, 10 deletions
diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index 5ef3819..263db6d 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -192,7 +192,11 @@ ext2_mount(mp, path, data, ndp, p) int error, flags; mode_t accessmode; - if ((error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args))) != 0) + /* Double-check the length of path.. */ + if (strlen(path) >= MAXMNTLEN - 1) + return (ENAMETOOLONG); + error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args)); + if (error != 0) return (error); /* * If updating, check whether changing from read-only to @@ -308,10 +312,12 @@ ext2_mount(mp, path, data, ndp, p) } ump = VFSTOUFS(mp); fs = ump->um_e2fs; - (void) copyinstr(path, fs->fs_fsmnt, sizeof(fs->fs_fsmnt) - 1, &size); - bzero(fs->fs_fsmnt + size, sizeof(fs->fs_fsmnt) - size); - bcopy((caddr_t)fs->fs_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname, - MNAMELEN); + /* + * Note that this strncpy() is ok because of a check at the start + * of ext2_mount(). + */ + strncpy(fs->fs_fsmnt, path, MAXMNTLEN); + fs->fs_fsmnt[MAXMNTLEN - 1] = '\0'; (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index 5ef3819..263db6d 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -192,7 +192,11 @@ ext2_mount(mp, path, data, ndp, p) int error, flags; mode_t accessmode; - if ((error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args))) != 0) + /* Double-check the length of path.. */ + if (strlen(path) >= MAXMNTLEN - 1) + return (ENAMETOOLONG); + error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args)); + if (error != 0) return (error); /* * If updating, check whether changing from read-only to @@ -308,10 +312,12 @@ ext2_mount(mp, path, data, ndp, p) } ump = VFSTOUFS(mp); fs = ump->um_e2fs; - (void) copyinstr(path, fs->fs_fsmnt, sizeof(fs->fs_fsmnt) - 1, &size); - bzero(fs->fs_fsmnt + size, sizeof(fs->fs_fsmnt) - size); - bcopy((caddr_t)fs->fs_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname, - MNAMELEN); + /* + * Note that this strncpy() is ok because of a check at the start + * of ext2_mount(). + */ + strncpy(fs->fs_fsmnt, path, MAXMNTLEN); + fs->fs_fsmnt[MAXMNTLEN - 1] = '\0'; (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); |