NFS: use new LSM interfaces to explicitly set mount options
Subsystems (4)
PATCH 1/1 NFS: use new LSM interfaces to explicitly set mount options
NFS and SELinux worked together previously because SELinux had NFS specific knowledge built in. This design was approved by both groups back in 2004 but the recent NFS changes to use nfs_parsed_mount_data and the usage of nfs_clone_mount_data showed this to be a poor fragile solution. This patch fixes the NFS functionality regression by making use of the new LSM interfaces to allow an FS to explicitly set its own mount options.
The explicit setting of mount options is done in the nfs get_sb functions which are called before the generic vfs hooks try to set mount options for filesystems which use text mount data.
This does not currently support NFSv4 as that functionality did not exist in previous kernels and thus there is no regression. I will be adding the needed code, which I believe to be the exact same as the v3 code, in nfs4_get_sb for 2.6.26.
---
fs/nfs/internal.h | 3 ++ fs/nfs/super.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-)
fs/nfs/internal.h +3 -0
@@ -3,6 +3,7 @@*/ #include <linux/mount.h> +#include <linux/security.h> struct nfs_string ;
@@ -57,6 +58,8 @@ struct nfs_parsed_mount_data {char *export_path;int protocol; } nfs_server; + +struct security_mnt_opts lsm_opts; };/* client.c */
fs/nfs/super.c +62 -2
131 lines not on this page · raw message
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 12 lines · Eric Paris
NFS and SELinux worked together previously because SELinux had NFS specific knowledge built in. This design was approved by both groups back in 2004 but the recent NFS changes to use
nfs_parsed_mount_dataand the usage ofnfs_clone_mount_datashowed this to be a poor fragile solution. This patch fixes the NFS functionality regression by making use of the new LSM interfaces to allow an FS to explicitly set its own mount options.The explicit setting of mount options is done in the nfs
get_sbfunctions which are called before the generic vfs hooks try to set mount options for filesystems which use text mount data.
Quoted 6 lines
This does not currently support NFSv4 as that functionality did not exist in previous kernels and thus there is no regression. I will be adding the needed code, which I believe to be the exact same as the v3 code, in
nfs4_get_sbfor 2.6.26.Signed-off-by Eric Paris <[email protected]>
James Morris
AppliedApplied. Pushing to Linus...
Signature · 2 lines
James Morris <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 1204744818.3216.254.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]
PATCH 1/1 NFS/LSM: Make NFSv4 set LSM mount options
NFSv3 get_sb operations call into the LSM layer to set security options passed from userspace. NFSv4 hooks were not originally added since it was reasonably late in the merge window and NFSv3 was the only thing that had regressed (v4 has never supported any LSM options)
This patch makes NFSv4 call into the LSM to set security options rather than just blindly dropping them with no notice to the user as happens today. This patch was tested in a simple NFSv4 environment with the context= option and appeared to work as expected.
---
fs/nfs/super.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
fs/nfs/super.c +10 -0
@@ -1946,6 +1946,10 @@ static int nfs4_get_sb(struct file_system_type *fs_type, goto error_splat_super; } + error =security_sb_set_mnt_opts (s, &data.lsm_opts); +if (error) + goto error_splat_root; + s->s_flags |=MS_ACTIVE ; mnt->mnt_sb = s; mnt->mnt_root = mntroot;
@@ -1962,6 +1966,8 @@ out_free:nfs_free_server (server); goto out; +error_splat_root: +dput (mntroot); error_splat_super:up_write (&s->s_umount);deactivate_super (s);
@@ -2041,6 +2047,8 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags, mnt->mnt_sb = s; mnt->mnt_root = mntroot; +security_sb_clone_mnt_opts (data->sb, s); +dprintk ("<-- nfs4_xdev_get_sb() = 0\n" );return 0 ;
@@ -2120,6 +2128,8 @@ static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags, mnt->mnt_sb = s; mnt->mnt_root = mntroot; +security_sb_clone_mnt_opts (data->sb, s); +dprintk ("<-- nfs4_referral_get_sb() = 0\n" );return 0 ;
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
A message that is not in the archive (sent off-list or not yet received): 1208441091.2985.8.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]
James Morris
Acked-byRe: [PATCH] NFS/LSM: Make NFSv4 set LSM mount options
Quoted 11 lines · Eric Paris
NFSv3
get_sboperations call into the LSM layer to set security options passed from userspace. NFSv4 hooks were not originally added since it was reasonably late in the merge window and NFSv3 was the only thing that had regressed (v4 has never supported any LSM options)This patch makes NFSv4 call into the LSM to set security options rather than just blindly dropping them with no notice to the user as happens today. This patch was tested in a simple NFSv4 environment with the context= option and appeared to work as expected.
Signed-off-by Eric Paris <[email protected]>
Signature · 7 lines
James Morris <[email protected]> -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
A message that is not in the archive (sent off-list or not yet received): Xine.LNX.4.64.0804180911570.23675-RC8Ws/[email protected]
Re: [PATCH] NFS/LSM: Make NFSv4 set LSM mount options
Quoted 7 lines · James Morris
Quoted 5 lines · Eric Paris
NFSv3
get_sboperations call into the LSM layer to set security options passed from userspace. NFSv4 hooks were not originally added since it was reasonably late in the merge window and NFSv3 was the only thing that had regressed (v4 has never supported any LSM options)
Quoted 8 lines
Quoted 6 lines
This patch makes NFSv4 call into the LSM to set security options rather than just blindly dropping them with no notice to the user as happens today. This patch was tested in a simple NFSv4 environment with the context= option and appeared to work as expected.
Signed-off-by Eric Paris <[email protected]>Acked-by James Morris <[email protected]>
Would any of the NFS people please ack and push this patch to linus? I don't want to ship 2.6.26 with NFSv4 continuing to just silently drop LSM mount options.
Thanks
-Eric
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.