Commit a08ee40a authored by Eric Sandeen's avatar Eric Sandeen Committed by Dave Chinner

xfs: sanitize remount options

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: default avatarEric Sandeen <sandeen@redhat.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 2e74af0e
...@@ -172,13 +172,17 @@ suffix_kstrtoint(const substring_t *s, unsigned int base, int *res) ...@@ -172,13 +172,17 @@ suffix_kstrtoint(const substring_t *s, unsigned int base, int *res)
* *
* Note that this function leaks the various device name allocations on * Note that this function leaks the various device name allocations on
* failure. The caller takes care of them. * failure. The caller takes care of them.
*
* *sb is const because this is also used to test options on the remount
* path, and we don't want this to have any side effects at remount time.
* Today this function does not change *sb, but just to future-proof...
*/ */
STATIC int STATIC int
xfs_parseargs( xfs_parseargs(
struct xfs_mount *mp, struct xfs_mount *mp,
char *options) char *options)
{ {
struct super_block *sb = mp->m_super; const struct super_block *sb = mp->m_super;
char *p; char *p;
substring_t args[MAX_OPT_ARGS]; substring_t args[MAX_OPT_ARGS];
int dsunit = 0; int dsunit = 0;
...@@ -1169,6 +1173,27 @@ xfs_quiesce_attr( ...@@ -1169,6 +1173,27 @@ xfs_quiesce_attr(
xfs_log_quiesce(mp); xfs_log_quiesce(mp);
} }
STATIC int
xfs_test_remount_options(
struct super_block *sb,
struct xfs_mount *mp,
char *options)
{
int error = 0;
struct xfs_mount *tmp_mp;
tmp_mp = kmem_zalloc(sizeof(*tmp_mp), KM_MAYFAIL);
if (!tmp_mp)
return -ENOMEM;
tmp_mp->m_super = sb;
error = xfs_parseargs(tmp_mp, options);
xfs_free_fsname(tmp_mp);
kfree(tmp_mp);
return error;
}
STATIC int STATIC int
xfs_fs_remount( xfs_fs_remount(
struct super_block *sb, struct super_block *sb,
...@@ -1181,6 +1206,11 @@ xfs_fs_remount( ...@@ -1181,6 +1206,11 @@ xfs_fs_remount(
char *p; char *p;
int error; 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); sync_filesystem(sb);
while ((p = strsep(&options, ",")) != NULL) { while ((p = strsep(&options, ",")) != NULL) {
int token; int token;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment