Author: kib
Date: Thu Feb  4 16:32:21 2016
New Revision: 295265
URL: https://svnweb.freebsd.org/changeset/base/295265

Log:
  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

Modified:
  head/sys/kern/vfs_mount.c

Modified: head/sys/kern/vfs_mount.c
==============================================================================
--- head/sys/kern/vfs_mount.c   Thu Feb  4 15:46:12 2016        (r295264)
+++ head/sys/kern/vfs_mount.c   Thu Feb  4 16:32:21 2016        (r295265)
@@ -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;
                }
        }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to