All of lore.kernel.org
 help / color / mirror / Atom feed
From: Elena Reshetova <elena.reshetova@intel.com>
To: kernel-hardening@lists.openwall.com
Cc: linux-security-module@vger.kernel.org, keescook@chromium.org,
	spender@grsecurity.net, jmorris@namei.org,
	casey.schaufler@intel.com, michael.leibowitz@intel.com,
	william.c.roberts@intel.com,
	Elena Reshetova <elena.reshetova@intel.com>
Subject: [kernel-hardening] [RFC] [PATCH 4/5] invoke path_chroot() LSM hook on mntns_install()
Date: Fri, 29 Jul 2016 10:34:39 +0300	[thread overview]
Message-ID: <1469777680-3687-5-git-send-email-elena.reshetova@intel.com> (raw)
In-Reply-To: <1469777680-3687-1-git-send-email-elena.reshetova@intel.com>

This adds an additional invocation of the
security_path_chroot LSM hook inside mntns_install().
Currently only capabilities are checked at this point,
while process root actually changes.

Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
---
 fs/namespace.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 419f746..c5dcb09 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3325,6 +3325,7 @@ static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
 	struct fs_struct *fs = current->fs;
 	struct mnt_namespace *mnt_ns = to_mnt_ns(ns);
 	struct path root;
+	int retval;
 
 	if (!ns_capable(mnt_ns->user_ns, CAP_SYS_ADMIN) ||
 	    !ns_capable(current_user_ns(), CAP_SYS_CHROOT) ||
@@ -3334,10 +3335,6 @@ static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
 	if (fs->users != 1)
 		return -EINVAL;
 
-	get_mnt_ns(mnt_ns);
-	put_mnt_ns(nsproxy->mnt_ns);
-	nsproxy->mnt_ns = mnt_ns;
-
 	/* Find the root */
 	root.mnt    = &mnt_ns->root->mnt;
 	root.dentry = mnt_ns->root->mnt.mnt_root;
@@ -3345,6 +3342,16 @@ static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
 	while(d_mountpoint(root.dentry) && follow_down_one(&root))
 		;
 
+	retval = security_path_chroot(&root);
+	if (retval) {
+		path_put(&root);
+		return retval;
+	}
+
+	get_mnt_ns(mnt_ns);
+	put_mnt_ns(nsproxy->mnt_ns);
+	nsproxy->mnt_ns = mnt_ns;
+
 	/* Update the pwd and root */
 	set_fs_pwd(fs, &root);
 	set_fs_root(fs, &root);
-- 
1.9.1

  parent reply	other threads:[~2016-07-29  7:34 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-29  7:34 [kernel-hardening] [RFC] [PATCH 0/5] Hardchroot LSM + additional hooks Elena Reshetova
2016-07-29  7:34 ` [kernel-hardening] [RFC] [PATCH 1/5] path_fchdir and path_fhandle LSM hooks Elena Reshetova
2016-07-29 18:12   ` Jann Horn
2016-07-31 10:55     ` Reshetova, Elena
2016-07-31 12:02       ` Jann Horn
2016-07-31 18:28         ` Reshetova, Elena
2016-07-31 21:23           ` Jann Horn
2016-08-01  8:38             ` Reshetova, Elena
2016-07-29  7:34 ` [kernel-hardening] [RFC] [PATCH 2/5] task_unshare LSM hook Elena Reshetova
2016-07-29 17:58   ` Jann Horn
2016-07-29 18:17     ` Reshetova, Elena
2016-07-29  7:34 ` [kernel-hardening] [RFC] [PATCH 3/5] sb_unsharefs " Elena Reshetova
2016-07-29 18:02   ` Jann Horn
2016-07-29 18:09     ` Reshetova, Elena
2016-07-29 18:15   ` Jann Horn
2016-07-29 18:19     ` Reshetova, Elena
2016-07-29  7:34 ` Elena Reshetova [this message]
2016-07-29 18:11   ` [kernel-hardening] [RFC] [PATCH 4/5] invoke path_chroot() LSM hook on mntns_install() Jann Horn
2016-07-31 10:39     ` Reshetova, Elena
2016-07-31 11:29       ` Jann Horn
2016-08-01  9:26         ` Reshetova, Elena
2016-07-29  7:34 ` [kernel-hardening] [RFC] [PATCH 5/5] Hardchroot LSM Elena Reshetova
2016-07-29 11:44   ` [kernel-hardening] " Brad Spengler
2016-07-29 12:15     ` [kernel-hardening] " Reshetova, Elena
2016-07-29 12:25     ` Reshetova, Elena
2016-07-29 18:53   ` [kernel-hardening] " Jann Horn
2016-07-29 19:20     ` Casey Schaufler
2016-07-29 20:53       ` Jann Horn
2016-07-29 21:10         ` Casey Schaufler
2016-07-29 21:50           ` Jann Horn
2016-07-30  6:10     ` Reshetova, Elena
2016-08-03  6:36 ` [kernel-hardening] Re: [RFC] [PATCH 0/5] Hardchroot LSM + additional hooks James Morris
2016-08-05  7:53   ` [kernel-hardening] " Reshetova, Elena

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=1469777680-3687-5-git-send-email-elena.reshetova@intel.com \
    --to=elena.reshetova@intel.com \
    --cc=casey.schaufler@intel.com \
    --cc=jmorris@namei.org \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-security-module@vger.kernel.org \
    --cc=michael.leibowitz@intel.com \
    --cc=spender@grsecurity.net \
    --cc=william.c.roberts@intel.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.