Skip to content

Commit

Permalink
nfs_remount(): don't leak, don't ignore LSM options quietly
Browse files Browse the repository at this point in the history
* if mount(2) passes something like "context=foo" with MS_REMOUNT
in flags (/sbin/mount.nfs will _not_ do that - you need to issue
the syscall manually), you'll get leaked copies for LSM options.
The reason is that instead of nfs_{alloc,free}_parsed_mount_data()
nfs_remount() uses kzalloc/kfree, which lacks the needed cleanup.

* selinux options are not changed on remount (as for any other
fs), but in case of NFS the failure is quiet - they are not compared
to what we used to have, with complaint in case of attempted changes.
Trivially fixed by converting to use of security_sb_remount().

Reviewed-by: David Howells <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Dec 21, 2018
1 parent a65001e commit 6a0440e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/nfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2254,7 +2254,7 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
options->version <= 6))))
return 0;

data = kzalloc(sizeof(*data), GFP_KERNEL);
data = nfs_alloc_parsed_mount_data();
if (data == NULL)
return -ENOMEM;

Expand Down Expand Up @@ -2293,8 +2293,10 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)

/* compare new mount options with old ones */
error = nfs_compare_remount_data(nfss, data);
if (!error)
error = security_sb_remount(sb, &data->lsm_opts);
out:
kfree(data);
nfs_free_parsed_mount_data(data);
return error;
}
EXPORT_SYMBOL_GPL(nfs_remount);
Expand Down

0 comments on commit 6a0440e

Please sign in to comment.