[PATCH 2/4] xfs: reject completely bogus remount options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There's a long comment about handling non-remountable
options in xfs_fs_remount, but nothing addresses the case
of completely bogus mount options at remount time, which
can lead to some severe strangeness:

# for I in `seq 1 10`; do mount -o remount,noacl /mnt/test2; done
# for I in `seq 1 10`; do mount -o remount,badoption /mnt/test2; done
# grep sdb4 /etc/mtab
/dev/sdb4 /mnt/test2 xfs rw,noacl,noacl,noacl,noacl,noacl,noacl,noacl,noacl,noacl,noacl,noacl,badoption,badoption,badoption,badoption,badoption,badoption,badoption,badoption,badoption,badoption 0 0

This is a bit of a hack, but we can re-use xfs_parseargs()
with a dummy mount struct to just vet all of the remount
options which were passed in.  With this, we get a saner
result:

[44898.102990] EXT4-fs (sdb4): Unrecognized mount option "badoption" or missing value

if we try to remount with something ridiculous.

In the long run we should probably revamp a lot of the mount option
handling...

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---

Note, not really sure what KM_* flag would be appropriate here,
if it fails, it really is ok, other than missing the verification.
But maybe that's too "nice?"

commit 72e6ddd901dc8a8ecb835324eb4e11b0d7ad8cf8
Author: Eric Sandeen <sandeen@xxxxxxxxxx>
Date:   Fri Oct 11 14:03:59 2013 -0500

    xfs: reject completely bogus remount options
    
    There's a long comment about handling non-remountable
    options in xfs_fs_remount, but nothing addresses the case
    of completely bogus mount options at remount time, which
    can lead to some severe strangeness:
    
    # for I in `seq 1 10`; do mount -o remount,noacl /mnt/test2; done
    # for I in `seq 1 10`; do mount -o remount,badoption /mnt/test2; done
    # grep sdb4 /etc/mtab
    /dev/sdb4 /mnt/test2 xfs rw,noacl,noacl,noacl,noacl,noacl,noacl,noacl,noacl,noacl,noacl,noacl,badoption,badoption,badoption,badoption,badoption,badoption,badoption,badoption,badoption,badoption 0 0
    
    This is a bit of a hack, but we can re-use xfs_parseargs()
    with a dummy mount struct to just vet all of the remount
    options which were passed in.  With this, we get a saner
    result:
    
    [44898.102990] EXT4-fs (sdb4): Unrecognized mount option "badoption" or missing value
    
    if we try to remount with something ridiculous.
    
    In the long run we should probably revamp a lot of the mount option
    handling...
    
    Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 15188cc..00a06d6 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1202,11 +1202,25 @@ xfs_fs_remount(
 	int			*flags,
 	char			*options)
 {
-	struct xfs_mount	*mp = XFS_M(sb);
+	struct xfs_mount	*mp = XFS_M(sb), *dummy_mp;
 	substring_t		args[MAX_OPT_ARGS];
 	char			*p;
 	int			error;
 
+	/*
+	 * Check all the mount options presented to be sure
+	 * there's nothing too crazy in there.  Non-remountable
+	 * but valid options are a different issue.
+	 */
+	dummy_mp = kmem_zalloc(sizeof(*dummy_mp), KM_MAYFAIL);
+	if (dummy_mp) {
+		dummy_mp->m_super = sb;
+		error = xfs_parseargs(dummy_mp, options);
+		kfree(dummy_mp);
+		if (error)
+			return -error;
+	}
+
 	while ((p = strsep(&options, ",")) != NULL) {
 		int token;
 

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs




[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux