* [PATCH 2/2-v2] NFS: use new LSM interfaces to explicitly set mount options
@ 2008-03-05 19:20 ` Eric Paris
0 siblings, 0 replies; 12+ messages in thread
From: Eric Paris @ 2008-03-05 19:20 UTC (permalink / raw)
To: linux-nfs, selinux, linux-security-module, linux-fsdevel
Cc: steved, jlayton, sds, jmorris, casey, trond.myklebust,
chuck.lever, hch, akpm
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.
Signed-off-by: Eric Paris <eparis@redhat.com>
---
fs/nfs/internal.h | 3 ++
fs/nfs/super.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 0f56196..9319927 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -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 */
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 1fb3818..fcf4b98 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -684,8 +684,9 @@ static void nfs_parse_server_address(char *value,
static int nfs_parse_mount_options(char *raw,
struct nfs_parsed_mount_data *mnt)
{
- char *p, *string;
+ char *p, *string, *secdata;
unsigned short port = 0;
+ int rc;
if (!raw) {
dfprintk(MOUNT, "NFS: mount options string was NULL.\n");
@@ -693,6 +694,20 @@ static int nfs_parse_mount_options(char *raw,
}
dfprintk(MOUNT, "NFS: nfs mount opts='%s'\n", raw);
+ secdata = alloc_secdata();
+ if (!secdata)
+ goto out_nomem;
+
+ rc = security_sb_copy_data(raw, secdata);
+ if (rc)
+ goto out_security_failure;
+
+ rc = security_sb_parse_opts_str(secdata, &mnt->lsm_opts);
+ if (rc)
+ goto out_security_failure;
+
+ free_secdata(secdata);
+
while ((p = strsep(&raw, ",")) != NULL) {
substring_t args[MAX_OPT_ARGS];
int option, token;
@@ -1042,7 +1057,10 @@ static int nfs_parse_mount_options(char *raw,
out_nomem:
printk(KERN_INFO "NFS: not enough memory to parse option\n");
return 0;
-
+out_security_failure:
+ free_secdata(secdata);
+ printk(KERN_INFO "NFS: security options invalid: %d\n", rc);
+ return 0;
out_unrec_vers:
printk(KERN_INFO "NFS: unrecognized NFS version number\n");
return 0;
@@ -1214,6 +1232,33 @@ static int nfs_validate_mount_data(void *options,
args->namlen = data->namlen;
args->bsize = data->bsize;
args->auth_flavors[0] = data->pseudoflavor;
+
+ /*
+ * The legacy version 6 binary mount data from userspace has a
+ * field used only to transport selinux information into the
+ * the kernel. To continue to support that functionality we
+ * have a touch of selinux knowledge here in the NFS code. The
+ * userspace code converted context=blah to just blah so we are
+ * converting back to the full string selinux understands.
+ */
+ if (data->context[0]){
+#ifdef CONFIG_SECURITY_SELINUX
+ int rc;
+ char *opts_str = kmalloc(sizeof(data->context) + 8, GFP_KERNEL);
+ if (!opts_str)
+ return -ENOMEM;
+ strcpy(opts_str, "context=");
+ data->context[NFS_MAX_CONTEXT_LEN] = '\0';
+ strcat(opts_str, &data->context[0]);
+ rc = security_sb_parse_opts_str(opts_str, &args->lsm_opts);
+ kfree(opts_str);
+ if (rc)
+ return rc;
+#else
+ return -EINVAL;
+#endif
+ }
+
break;
default: {
unsigned int len;
@@ -1476,6 +1521,8 @@ static int nfs_get_sb(struct file_system_type *fs_type,
};
int error;
+ security_init_mnt_opts(&data.lsm_opts);
+
/* Validate the mount data */
error = nfs_validate_mount_data(raw_data, &data, &mntfh, dev_name);
if (error < 0)
@@ -1515,6 +1562,10 @@ static int nfs_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;
@@ -1523,12 +1574,15 @@ static int nfs_get_sb(struct file_system_type *fs_type,
out:
kfree(data.nfs_server.hostname);
kfree(data.mount_server.hostname);
+ security_free_mnt_opts(&data.lsm_opts);
return error;
out_err_nosb:
nfs_free_server(server);
goto out;
+error_splat_root:
+ dput(mntroot);
error_splat_super:
up_write(&s->s_umount);
deactivate_super(s);
@@ -1608,6 +1662,9 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
mnt->mnt_sb = s;
mnt->mnt_root = mntroot;
+ /* clone any lsm security options from the parent to the new sb */
+ security_sb_clone_mnt_opts(data->sb, s);
+
dprintk("<-- nfs_xdev_get_sb() = 0\n");
return 0;
@@ -1850,6 +1907,8 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
};
int error;
+ security_init_mnt_opts(&data.lsm_opts);
+
/* Validate the mount data */
error = nfs4_validate_mount_data(raw_data, &data, dev_name);
if (error < 0)
@@ -1898,6 +1957,7 @@ out:
kfree(data.client_address);
kfree(data.nfs_server.export_path);
kfree(data.nfs_server.hostname);
+ security_free_mnt_opts(&data.lsm_opts);
return error;
out_free:
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/2-v2] NFS: use new LSM interfaces to explicitly set mount options
@ 2008-03-05 19:20 ` Eric Paris
0 siblings, 0 replies; 12+ messages in thread
From: Eric Paris @ 2008-03-05 19:20 UTC (permalink / raw)
To: linux-nfs, selinux, linux-security-module, linux-fsdevel
Cc: steved, jlayton, sds, jmorris, casey, trond.myklebust,
chuck.lever, hch, akpm
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.
Signed-off-by: Eric Paris <eparis@redhat.com>
---
fs/nfs/internal.h | 3 ++
fs/nfs/super.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 0f56196..9319927 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -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 */
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 1fb3818..fcf4b98 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -684,8 +684,9 @@ static void nfs_parse_server_address(char *value,
static int nfs_parse_mount_options(char *raw,
struct nfs_parsed_mount_data *mnt)
{
- char *p, *string;
+ char *p, *string, *secdata;
unsigned short port = 0;
+ int rc;
if (!raw) {
dfprintk(MOUNT, "NFS: mount options string was NULL.\n");
@@ -693,6 +694,20 @@ static int nfs_parse_mount_options(char *raw,
}
dfprintk(MOUNT, "NFS: nfs mount opts='%s'\n", raw);
+ secdata = alloc_secdata();
+ if (!secdata)
+ goto out_nomem;
+
+ rc = security_sb_copy_data(raw, secdata);
+ if (rc)
+ goto out_security_failure;
+
+ rc = security_sb_parse_opts_str(secdata, &mnt->lsm_opts);
+ if (rc)
+ goto out_security_failure;
+
+ free_secdata(secdata);
+
while ((p = strsep(&raw, ",")) != NULL) {
substring_t args[MAX_OPT_ARGS];
int option, token;
@@ -1042,7 +1057,10 @@ static int nfs_parse_mount_options(char *raw,
out_nomem:
printk(KERN_INFO "NFS: not enough memory to parse option\n");
return 0;
-
+out_security_failure:
+ free_secdata(secdata);
+ printk(KERN_INFO "NFS: security options invalid: %d\n", rc);
+ return 0;
out_unrec_vers:
printk(KERN_INFO "NFS: unrecognized NFS version number\n");
return 0;
@@ -1214,6 +1232,33 @@ static int nfs_validate_mount_data(void *options,
args->namlen = data->namlen;
args->bsize = data->bsize;
args->auth_flavors[0] = data->pseudoflavor;
+
+ /*
+ * The legacy version 6 binary mount data from userspace has a
+ * field used only to transport selinux information into the
+ * the kernel. To continue to support that functionality we
+ * have a touch of selinux knowledge here in the NFS code. The
+ * userspace code converted context=blah to just blah so we are
+ * converting back to the full string selinux understands.
+ */
+ if (data->context[0]){
+#ifdef CONFIG_SECURITY_SELINUX
+ int rc;
+ char *opts_str = kmalloc(sizeof(data->context) + 8, GFP_KERNEL);
+ if (!opts_str)
+ return -ENOMEM;
+ strcpy(opts_str, "context=");
+ data->context[NFS_MAX_CONTEXT_LEN] = '\0';
+ strcat(opts_str, &data->context[0]);
+ rc = security_sb_parse_opts_str(opts_str, &args->lsm_opts);
+ kfree(opts_str);
+ if (rc)
+ return rc;
+#else
+ return -EINVAL;
+#endif
+ }
+
break;
default: {
unsigned int len;
@@ -1476,6 +1521,8 @@ static int nfs_get_sb(struct file_system_type *fs_type,
};
int error;
+ security_init_mnt_opts(&data.lsm_opts);
+
/* Validate the mount data */
error = nfs_validate_mount_data(raw_data, &data, &mntfh, dev_name);
if (error < 0)
@@ -1515,6 +1562,10 @@ static int nfs_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;
@@ -1523,12 +1574,15 @@ static int nfs_get_sb(struct file_system_type *fs_type,
out:
kfree(data.nfs_server.hostname);
kfree(data.mount_server.hostname);
+ security_free_mnt_opts(&data.lsm_opts);
return error;
out_err_nosb:
nfs_free_server(server);
goto out;
+error_splat_root:
+ dput(mntroot);
error_splat_super:
up_write(&s->s_umount);
deactivate_super(s);
@@ -1608,6 +1662,9 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
mnt->mnt_sb = s;
mnt->mnt_root = mntroot;
+ /* clone any lsm security options from the parent to the new sb */
+ security_sb_clone_mnt_opts(data->sb, s);
+
dprintk("<-- nfs_xdev_get_sb() = 0\n");
return 0;
@@ -1850,6 +1907,8 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
};
int error;
+ security_init_mnt_opts(&data.lsm_opts);
+
/* Validate the mount data */
error = nfs4_validate_mount_data(raw_data, &data, dev_name);
if (error < 0)
@@ -1898,6 +1957,7 @@ out:
kfree(data.client_address);
kfree(data.nfs_server.export_path);
kfree(data.nfs_server.hostname);
+ security_free_mnt_opts(&data.lsm_opts);
return error;
out_free:
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/2-v2] NFS: use new LSM interfaces to explicitly set mount options
@ 2008-03-05 19:20 ` Eric Paris
0 siblings, 0 replies; 12+ messages in thread
From: Eric Paris @ 2008-03-05 19:20 UTC (permalink / raw)
To: linux-nfs-u79uwXL29TY76Z2rM5mHXA, selinux-+05T5uksL2qpZYMLLGbcSA,
linux-security-module-u79uwXL29TY76Z2rM5mHXA,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA
Cc: steved-H+wXaHxf7aLQT0dZR+AlfA, jlayton-H+wXaHxf7aLQT0dZR+AlfA,
sds-+05T5uksL2qpZYMLLGbcSA, jmorris-gx6/JNMH7DfYtjvyW6yDsg,
casey-iSGtlc1asvQWG2LlvL+J4A,
trond.myklebust-41N18TsMXrtuMpJDpNschA,
chuck.lever-QHcLZuEGTsvQT0dZR+AlfA, hch-wEGCiKHe2LqWVfeAwA7xHQ,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b
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.
Signed-off-by: Eric Paris <eparis-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
fs/nfs/internal.h | 3 ++
fs/nfs/super.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 0f56196..9319927 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -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 */
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 1fb3818..fcf4b98 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -684,8 +684,9 @@ static void nfs_parse_server_address(char *value,
static int nfs_parse_mount_options(char *raw,
struct nfs_parsed_mount_data *mnt)
{
- char *p, *string;
+ char *p, *string, *secdata;
unsigned short port = 0;
+ int rc;
if (!raw) {
dfprintk(MOUNT, "NFS: mount options string was NULL.\n");
@@ -693,6 +694,20 @@ static int nfs_parse_mount_options(char *raw,
}
dfprintk(MOUNT, "NFS: nfs mount opts='%s'\n", raw);
+ secdata = alloc_secdata();
+ if (!secdata)
+ goto out_nomem;
+
+ rc = security_sb_copy_data(raw, secdata);
+ if (rc)
+ goto out_security_failure;
+
+ rc = security_sb_parse_opts_str(secdata, &mnt->lsm_opts);
+ if (rc)
+ goto out_security_failure;
+
+ free_secdata(secdata);
+
while ((p = strsep(&raw, ",")) != NULL) {
substring_t args[MAX_OPT_ARGS];
int option, token;
@@ -1042,7 +1057,10 @@ static int nfs_parse_mount_options(char *raw,
out_nomem:
printk(KERN_INFO "NFS: not enough memory to parse option\n");
return 0;
-
+out_security_failure:
+ free_secdata(secdata);
+ printk(KERN_INFO "NFS: security options invalid: %d\n", rc);
+ return 0;
out_unrec_vers:
printk(KERN_INFO "NFS: unrecognized NFS version number\n");
return 0;
@@ -1214,6 +1232,33 @@ static int nfs_validate_mount_data(void *options,
args->namlen = data->namlen;
args->bsize = data->bsize;
args->auth_flavors[0] = data->pseudoflavor;
+
+ /*
+ * The legacy version 6 binary mount data from userspace has a
+ * field used only to transport selinux information into the
+ * the kernel. To continue to support that functionality we
+ * have a touch of selinux knowledge here in the NFS code. The
+ * userspace code converted context=blah to just blah so we are
+ * converting back to the full string selinux understands.
+ */
+ if (data->context[0]){
+#ifdef CONFIG_SECURITY_SELINUX
+ int rc;
+ char *opts_str = kmalloc(sizeof(data->context) + 8, GFP_KERNEL);
+ if (!opts_str)
+ return -ENOMEM;
+ strcpy(opts_str, "context=");
+ data->context[NFS_MAX_CONTEXT_LEN] = '\0';
+ strcat(opts_str, &data->context[0]);
+ rc = security_sb_parse_opts_str(opts_str, &args->lsm_opts);
+ kfree(opts_str);
+ if (rc)
+ return rc;
+#else
+ return -EINVAL;
+#endif
+ }
+
break;
default: {
unsigned int len;
@@ -1476,6 +1521,8 @@ static int nfs_get_sb(struct file_system_type *fs_type,
};
int error;
+ security_init_mnt_opts(&data.lsm_opts);
+
/* Validate the mount data */
error = nfs_validate_mount_data(raw_data, &data, &mntfh, dev_name);
if (error < 0)
@@ -1515,6 +1562,10 @@ static int nfs_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;
@@ -1523,12 +1574,15 @@ static int nfs_get_sb(struct file_system_type *fs_type,
out:
kfree(data.nfs_server.hostname);
kfree(data.mount_server.hostname);
+ security_free_mnt_opts(&data.lsm_opts);
return error;
out_err_nosb:
nfs_free_server(server);
goto out;
+error_splat_root:
+ dput(mntroot);
error_splat_super:
up_write(&s->s_umount);
deactivate_super(s);
@@ -1608,6 +1662,9 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
mnt->mnt_sb = s;
mnt->mnt_root = mntroot;
+ /* clone any lsm security options from the parent to the new sb */
+ security_sb_clone_mnt_opts(data->sb, s);
+
dprintk("<-- nfs_xdev_get_sb() = 0\n");
return 0;
@@ -1850,6 +1907,8 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
};
int error;
+ security_init_mnt_opts(&data.lsm_opts);
+
/* Validate the mount data */
error = nfs4_validate_mount_data(raw_data, &data, dev_name);
if (error < 0)
@@ -1898,6 +1957,7 @@ out:
kfree(data.client_address);
kfree(data.nfs_server.export_path);
kfree(data.nfs_server.hostname);
+ security_free_mnt_opts(&data.lsm_opts);
return error;
out_free:
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2-v2] NFS: use new LSM interfaces to explicitly set mount options
2008-03-05 19:20 ` Eric Paris
(?)
(?)
@ 2008-03-05 19:34 ` Trond Myklebust
2008-03-05 22:12 ` James Morris
-1 siblings, 1 reply; 12+ messages in thread
From: Trond Myklebust @ 2008-03-05 19:34 UTC (permalink / raw)
To: Eric Paris
Cc: linux-nfs, selinux, linux-security-module, linux-fsdevel, steved,
jlayton, sds, jmorris, casey, chuck.lever, hch, akpm
On Wed, 2008-03-05 at 14:20 -0500, Eric Paris wrote:
> 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.
>
> Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2-v2] NFS: use new LSM interfaces to explicitly set mount options
2008-03-05 19:34 ` Trond Myklebust
@ 2008-03-05 22:12 ` James Morris
0 siblings, 0 replies; 12+ messages in thread
From: James Morris @ 2008-03-05 22:12 UTC (permalink / raw)
To: Trond Myklebust
Cc: Eric Paris, linux-nfs, selinux, linux-security-module,
linux-fsdevel, steved, jlayton, sds, casey, chuck.lever, hch,
akpm
Applied. Pushing to Linus...
--
James Morris
<jmorris@namei.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2-v2] NFS: use new LSM interfaces to explicitly set mount options
@ 2008-03-05 22:12 ` James Morris
0 siblings, 0 replies; 12+ messages in thread
From: James Morris @ 2008-03-05 22:12 UTC (permalink / raw)
To: Trond Myklebust
Cc: Eric Paris, linux-nfs, selinux, linux-security-module,
linux-fsdevel, steved, jlayton, sds, casey, chuck.lever, hch,
akpm
Applied. Pushing to Linus...
--
James Morris
<jmorris@namei.org>
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] NFS/LSM: Make NFSv4 set LSM mount options
2008-03-05 19:20 ` Eric Paris
@ 2008-04-17 14:04 ` Eric Paris
-1 siblings, 0 replies; 12+ messages in thread
From: Eric Paris @ 2008-04-17 14:04 UTC (permalink / raw)
To: linux-nfs
Cc: selinux, linux-security-module, steved, jlayton, sds, jmorris,
chuck.lever, akpm
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.
Signed-off-by: Eric Paris <eparis@redhat.com>
---
fs/nfs/super.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index f921902..ffd46f8 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -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;
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH] NFS/LSM: Make NFSv4 set LSM mount options
@ 2008-04-17 14:04 ` Eric Paris
0 siblings, 0 replies; 12+ messages in thread
From: Eric Paris @ 2008-04-17 14:04 UTC (permalink / raw)
To: linux-nfs
Cc: selinux, linux-security-module, steved, jlayton, sds, jmorris,
chuck.lever, akpm
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.
Signed-off-by: Eric Paris <eparis@redhat.com>
---
fs/nfs/super.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index f921902..ffd46f8 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -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 majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] NFS/LSM: Make NFSv4 set LSM mount options
2008-04-17 14:04 ` Eric Paris
@ 2008-04-17 23:12 ` James Morris
-1 siblings, 0 replies; 12+ messages in thread
From: James Morris @ 2008-04-17 23:12 UTC (permalink / raw)
To: Eric Paris
Cc: linux-nfs, selinux, linux-security-module, steved, jlayton, sds,
chuck.lever, akpm
On Thu, 17 Apr 2008, Eric Paris wrote:
> 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.
>
> Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
--
James Morris
<jmorris@namei.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] NFS/LSM: Make NFSv4 set LSM mount options
@ 2008-04-17 23:12 ` James Morris
0 siblings, 0 replies; 12+ messages in thread
From: James Morris @ 2008-04-17 23:12 UTC (permalink / raw)
To: Eric Paris
Cc: linux-nfs, selinux, linux-security-module, steved, jlayton, sds,
chuck.lever, akpm
On Thu, 17 Apr 2008, Eric Paris wrote:
> 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.
>
> Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
--
James Morris
<jmorris@namei.org>
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] NFS/LSM: Make NFSv4 set LSM mount options
2008-04-17 23:12 ` James Morris
@ 2008-04-30 16:47 ` Eric Paris
-1 siblings, 0 replies; 12+ messages in thread
From: Eric Paris @ 2008-04-30 16:47 UTC (permalink / raw)
To: James Morris
Cc: linux-nfs, selinux, linux-security-module, steved, jlayton, sds,
chuck.lever, akpm
On Fri, 2008-04-18 at 09:12 +1000, James Morris wrote:
> On Thu, 17 Apr 2008, Eric Paris wrote:
>
> > 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.
> >
> > Signed-off-by: Eric Paris <eparis@redhat.com>
>
> Acked-by: James Morris <jmorris@namei.org>
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] NFS/LSM: Make NFSv4 set LSM mount options
@ 2008-04-30 16:47 ` Eric Paris
0 siblings, 0 replies; 12+ messages in thread
From: Eric Paris @ 2008-04-30 16:47 UTC (permalink / raw)
To: James Morris
Cc: linux-nfs, selinux, linux-security-module, steved, jlayton, sds,
chuck.lever, akpm
On Fri, 2008-04-18 at 09:12 +1000, James Morris wrote:
> On Thu, 17 Apr 2008, Eric Paris wrote:
>
> > 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.
> >
> > Signed-off-by: Eric Paris <eparis@redhat.com>
>
> Acked-by: James Morris <jmorris@namei.org>
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 majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-04-30 16:48 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-05 19:20 [PATCH 2/2-v2] NFS: use new LSM interfaces to explicitly set mount options Eric Paris
2008-03-05 19:20 ` Eric Paris
2008-03-05 19:20 ` Eric Paris
2008-03-05 19:34 ` Trond Myklebust
2008-03-05 22:12 ` James Morris
2008-03-05 22:12 ` James Morris
[not found] ` <1204744818.3216.254.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2008-04-17 14:04 ` [PATCH] NFS/LSM: Make NFSv4 set LSM " Eric Paris
2008-04-17 14:04 ` Eric Paris
[not found] ` <1208441091.2985.8.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2008-04-17 23:12 ` James Morris
2008-04-17 23:12 ` James Morris
[not found] ` <Xine.LNX.4.64.0804180911570.23675-RC8Ws/H8zzudju81dFSl6rpzq4S04n8Q@public.gmane.org>
2008-04-30 16:47 ` Eric Paris
2008-04-30 16:47 ` Eric Paris
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.