mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bosrsf04@gmail.com
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Kees Cook <keescook@chromium.org>, Arnd Bergmann <arnd@arndb.de>,
	Ingo Molnar <mingo@kernel.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Andy Lutomirski <luto@kernel.org>,
	Nicolas Pitre <nicolas.pitre@linaro.org>,
	Petr Mladek <pmladek@suse.com>, Helge Deller <deller@gmx.de>,
	Rik van Riel <riel@redhat.com>,
	Thomas Garnier <thgarnie@google.com>,
	Parav Pandit <pandit.parav@gmail.com>,
	"seokhoon . yoon" <iamyooon@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Dave Hansen <dave.hansen@intel.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: josh@joshtriplett.org, brkkurek192@gmail.com,
	conorcurry@gmail.com, fanofbond138@gmail.com,
	Brian Ashworth <bosrsf04@gmail.com>
Subject: [PATCH 1/3] fs: Makes functions used by pivot_root accessible
Date: Fri, 24 Feb 2017 19:21:49 -0500	[thread overview]
Message-ID: <df6020cb3d126d3f811bb3da8d1171660d7a7379.1487974517.git.bosrsf04@gmail.com> (raw)
In-Reply-To: <cover.1487974516.git.bosrsf04@gmail.com>

From: Brian Ashworth <bosrsf04@gmail.com>

add/remove: 1/0 grow/shrink: 0/2 up/down: 19/-44 (-25)
function                                     old     new   delta
detach_mnt                                     -      19     +19
attach_recursive_mnt                         349     331     -18
sys_pivot_root                               636     610     -26
Total: Before=1899598, After=1899573, chg -0.00%

Signed-off-by: Brian Ashworth <bosrsf04@gmail.com>
---
 fs/mount.h     | 24 ++++++++++++++++++++++++
 fs/namespace.c | 27 ++++++---------------------
 2 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/fs/mount.h b/fs/mount.h
index 2c856fc47ae3..c228d0c233e8 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -3,6 +3,7 @@
 #include <linux/poll.h>
 #include <linux/ns_common.h>
 #include <linux/fs_pin.h>
+#include <linux/nsproxy.h>
 
 struct mnt_namespace {
 	atomic_t		count;
@@ -145,3 +146,26 @@ static inline bool is_local_mountpoint(struct dentry *dentry)
 
 	return __is_local_mountpoint(dentry);
 }
+
+/*
+ * Is the caller allowed to modify his namespace?
+ */
+static inline bool may_mount(void)
+{
+	return ns_capable(current->nsproxy->mnt_ns->user_ns, CAP_SYS_ADMIN);
+}
+
+static inline int check_mnt(struct mount *mnt)
+{
+	return mnt->mnt_ns == current->nsproxy->mnt_ns;
+}
+
+struct mountpoint *lock_mount(struct path *path);
+void unlock_mount(struct mountpoint *where);
+
+void detach_mnt(struct mount *mnt, struct path *old_path);
+void attach_mnt(struct mount *mnt, struct mount *parent, struct mountpoint *mp);
+
+void touch_mnt_namespace(struct mnt_namespace *ns);
+
+void put_mountpoint(struct mountpoint *mp);
diff --git a/fs/namespace.c b/fs/namespace.c
index 487ba30bb5c6..d49d615e30a1 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -789,7 +789,7 @@ static struct mountpoint *get_mountpoint(struct dentry *dentry)
 	return mp;
 }
 
-static void put_mountpoint(struct mountpoint *mp)
+void put_mountpoint(struct mountpoint *mp)
 {
 	if (!--mp->m_count) {
 		struct dentry *dentry = mp->m_dentry;
@@ -802,15 +802,10 @@ static void put_mountpoint(struct mountpoint *mp)
 	}
 }
 
-static inline int check_mnt(struct mount *mnt)
-{
-	return mnt->mnt_ns == current->nsproxy->mnt_ns;
-}
-
 /*
  * vfsmount lock must be held for write
  */
-static void touch_mnt_namespace(struct mnt_namespace *ns)
+void touch_mnt_namespace(struct mnt_namespace *ns)
 {
 	if (ns) {
 		ns->event = ++event;
@@ -846,7 +841,7 @@ static void unhash_mnt(struct mount *mnt)
 /*
  * vfsmount lock must be held for write
  */
-static void detach_mnt(struct mount *mnt, struct path *old_path)
+void detach_mnt(struct mount *mnt, struct path *old_path)
 {
 	old_path->dentry = mnt->mnt_mountpoint;
 	old_path->mnt = &mnt->mnt_parent->mnt;
@@ -881,9 +876,7 @@ void mnt_set_mountpoint(struct mount *mnt,
 /*
  * vfsmount lock must be held for write
  */
-static void attach_mnt(struct mount *mnt,
-			struct mount *parent,
-			struct mountpoint *mp)
+void attach_mnt(struct mount *mnt, struct mount *parent, struct mountpoint *mp)
 {
 	mnt_set_mountpoint(parent, mp, mnt);
 	hlist_add_head_rcu(&mnt->mnt_hash, m_hash(&parent->mnt, mp->m_dentry));
@@ -1639,14 +1632,6 @@ void __detach_mounts(struct dentry *dentry)
 	namespace_unlock();
 }
 
-/* 
- * Is the caller allowed to modify his namespace?
- */
-static inline bool may_mount(void)
-{
-	return ns_capable(current->nsproxy->mnt_ns->user_ns, CAP_SYS_ADMIN);
-}
-
 static inline bool may_mandlock(void)
 {
 #ifndef	CONFIG_MANDATORY_FILE_LOCKING
@@ -2049,7 +2034,7 @@ static int attach_recursive_mnt(struct mount *source_mnt,
 	return err;
 }
 
-static struct mountpoint *lock_mount(struct path *path)
+struct mountpoint *lock_mount(struct path *path)
 {
 	struct vfsmount *mnt;
 	struct dentry *dentry = path->dentry;
@@ -2078,7 +2063,7 @@ static struct mountpoint *lock_mount(struct path *path)
 	goto retry;
 }
 
-static void unlock_mount(struct mountpoint *where)
+void unlock_mount(struct mountpoint *where)
 {
 	struct dentry *dentry = where->m_dentry;
 
-- 
2.11.1

  reply	other threads:[~2017-02-25  0:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-25  0:21 [PATCH 0/3] fs: Support compiling out the pivot_root syscall bosrsf04
2017-02-25  0:21 ` bosrsf04 [this message]
2017-02-25  0:21 ` [PATCH 2/3] fs: Extracts pivot_root so it can be made optional bosrsf04
2017-02-25 15:22   ` Theodore Ts'o
2017-02-25 16:06     ` Al Viro
2017-02-26  0:54       ` [PATCH 0/1] fs: Support compiling out the pivot_root syscall Brian Ashworth
2017-02-26  0:54         ` [PATCH 1/1] fs: Allows for the pivot_root syscall to be optional Brian Ashworth
2017-02-26  1:14           ` Nicolas Pitre
2017-03-29 20:38             ` bosrsf04
2017-02-25  0:21 ` [PATCH 3/3] fs: Allows for the pivot_root syscall to be omitted bosrsf04
2017-02-25 15:18 ` [PATCH 0/3] fs: Support compiling out the pivot_root syscall Nicolas Pitre

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=df6020cb3d126d3f811bb3da8d1171660d7a7379.1487974517.git.bosrsf04@gmail.com \
    --to=bosrsf04@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=ard.biesheuvel@linaro.org \
    --cc=arnd@arndb.de \
    --cc=brkkurek192@gmail.com \
    --cc=conorcurry@gmail.com \
    --cc=dave.hansen@intel.com \
    --cc=deller@gmx.de \
    --cc=fanofbond138@gmail.com \
    --cc=iamyooon@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=nicolas.pitre@linaro.org \
    --cc=pandit.parav@gmail.com \
    --cc=pmladek@suse.com \
    --cc=riel@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=thgarnie@google.com \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®