nfs: fix regression in handling of context= option in NFSv4
commit7c8b708b0718d9fbff3aca2927e3daa3a8f719d4
authorJeff Layton <jlayton@redhat.com>
Tue, 20 Dec 2011 11:57:45 +0000 (20 06:57 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 18 Jan 2012 15:31:55 +0000 (18 07:31 -0800)
tree899e3b6a69a49be9b7e46ef1ab5bc95b6fec39be
parentbd689a8cdbfe4cf5182f01aa93e4ba3fadf1f11c
nfs: fix regression in handling of context= option in NFSv4

commit 8a0d551a59ac92d8ff048d6cb29d3a02073e81e8 upstream.

Setting the security context of a NFSv4 mount via the context= mount
option is currently broken. The NFSv4 codepath allocates a parsed
options struct, and then parses the mount options to fill it. It
eventually calls nfs4_remote_mount which calls security_init_mnt_opts.
That clobbers the lsm_opts struct that was populated earlier. This bug
also looks like it causes a small memory leak on each v4 mount where
context= is used.

Fix this by moving the initialization of the lsm_opts into
nfs_alloc_parsed_mount_data. Also, add a destructor for
nfs_parsed_mount_data to make it easier to free all of the allocations
hanging off of it, and to ensure that the security_free_mnt_opts is
called whenever security_init_mnt_opts is.

I believe this regression was introduced quite some time ago, probably
by commit c02d7adf.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/nfs/super.c