summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-02-04 16:32:21 +0000
committerkib <kib@FreeBSD.org>2016-02-04 16:32:21 +0000
commit55fda5017767c3c7da549cc9a384bc668e70e185 (patch)
tree1075d0ce797cf8900c5c53e2daeac8dd0a0ea135 /sys/kern
parentc73d67730ab2dedcdc1b171947392eecc94ba6dd (diff)
downloadFreeBSD-src-55fda5017767c3c7da549cc9a384bc668e70e185.zip
FreeBSD-src-55fda5017767c3c7da549cc9a384bc668e70e185.tar.gz
Do not copy by field when converting struct oexport_args to struct
export_args on mount update, bzero() is consistent with vfs_oexport_conv(). Make the code structure more explicit by using switch. Return EINVAL if export option layout (deduced from size) is unknown. Based on the submission by: bde Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_mount.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 3ca995f..505da75 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -880,10 +880,10 @@ vfs_domount_update(
struct vfsoptlist **optlist /* Options local to the filesystem. */
)
{
- struct oexport_args oexport;
struct export_args export;
+ void *bufp;
struct mount *mp;
- int error, export_error;
+ int error, export_error, len;
uint64_t flag;
ASSERT_VOP_ELOCKED(vp, __func__);
@@ -951,23 +951,21 @@ vfs_domount_update(
error = VFS_MOUNT(mp);
export_error = 0;
- if (error == 0) {
- /* Process the export option. */
- if (vfs_copyopt(mp->mnt_optnew, "export", &export,
- sizeof(export)) == 0) {
- export_error = vfs_export(mp, &export);
- } else if (vfs_copyopt(mp->mnt_optnew, "export", &oexport,
- sizeof(oexport)) == 0) {
- export.ex_flags = oexport.ex_flags;
- export.ex_root = oexport.ex_root;
- export.ex_anon = oexport.ex_anon;
- export.ex_addr = oexport.ex_addr;
- export.ex_addrlen = oexport.ex_addrlen;
- export.ex_mask = oexport.ex_mask;
- export.ex_masklen = oexport.ex_masklen;
- export.ex_indexfile = oexport.ex_indexfile;
- export.ex_numsecflavors = 0;
+ /* Process the export option. */
+ if (error == 0 && vfs_getopt(mp->mnt_optnew, "export", &bufp,
+ &len) == 0) {
+ /* Assume that there is only 1 ABI for each length. */
+ switch (len) {
+ case (sizeof(struct oexport_args)):
+ bzero(&export, sizeof(export));
+ /* FALLTHROUGH */
+ case (sizeof(export)):
+ bcopy(bufp, &export, len);
export_error = vfs_export(mp, &export);
+ break;
+ default:
+ export_error = EINVAL;
+ break;
}
}
OpenPOWER on IntegriCloud