xfs
[Top] [All Lists]

[PATCH 2/3] xfs: sanitize remount options

To: xfs@xxxxxxxxxxx
Subject: [PATCH 2/3] xfs: sanitize remount options
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Wed, 10 Feb 2016 17:40:05 -0600
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <56BBC982.50804@xxxxxxxxxx>
References: <56BBC982.50804@xxxxxxxxxx>
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.5.1
Perform basic sanitization of remount options by
passing the option string and a dummy mount structure
through xfs_parseargs and returning the result.

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

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 934233a..d1cd4fa 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1168,6 +1168,27 @@ xfs_quiesce_attr(
 }
 
 STATIC int
+xfs_test_remount_options(
+       struct super_block      *sb,
+       struct xfs_mount        *mp,
+       char                    *options)
+{
+       int                     error = 0;
+       struct xfs_mount        *tmp;
+
+       tmp = kmem_zalloc(sizeof(*tmp), KM_MAYFAIL);
+       if (!tmp)
+               return -ENOMEM;
+
+       tmp->m_super = sb;
+       error = xfs_parseargs(tmp, options);
+       xfs_free_fsname(tmp);
+       kfree(tmp);
+
+       return error;
+}
+
+STATIC int
 xfs_fs_remount(
        struct super_block      *sb,
        int                     *flags,
@@ -1179,6 +1200,11 @@ xfs_fs_remount(
        char                    *p;
        int                     error;
 
+       /* First, check for complete junk; i.e. invalid options */
+       error = xfs_test_remount_options(sb, mp, options);
+       if (error)
+               return error;
+
        sync_filesystem(sb);
        while ((p = strsep(&options, ",")) != NULL) {
                int token;


<Prev in Thread] Current Thread [Next in Thread>