All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Paris <eparis@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org,
	steved@redhat.com, jlayton@redhat.com, sds@tycho.nsa.gov,
	jmorris@namei.org, chuck.lever@oracle.com,
	akpm@linux-foundation.org
Subject: [PATCH] NFS/LSM: Make NFSv4 set LSM mount options
Date: Thu, 17 Apr 2008 10:04:51 -0400	[thread overview]
Message-ID: <1208441091.2985.8.camel@localhost.localdomain> (raw)
In-Reply-To: <1204744818.3216.254.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>

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;
 



WARNING: multiple messages have this Message-ID (diff)
From: Eric Paris <eparis@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org,
	steved@redhat.com, jlayton@redhat.com, sds@tycho.nsa.gov,
	jmorris@namei.org, chuck.lever@oracle.com,
	akpm@linux-foundation.org
Subject: [PATCH] NFS/LSM: Make NFSv4 set LSM mount options
Date: Thu, 17 Apr 2008 10:04:51 -0400	[thread overview]
Message-ID: <1208441091.2985.8.camel@localhost.localdomain> (raw)
In-Reply-To: <1204744818.3216.254.camel@localhost.localdomain>

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.

  parent reply	other threads:[~2008-04-17 14:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Eric Paris [this message]
2008-04-17 14:04     ` [PATCH] NFS/LSM: Make NFSv4 set LSM " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1208441091.2985.8.camel@localhost.localdomain \
    --to=eparis@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=chuck.lever@oracle.com \
    --cc=jlayton@redhat.com \
    --cc=jmorris@namei.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.