lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 24 Feb 2017 19:21:49 -0500
From:   bosrsf04@...il.com
To:     Alexander Viro <viro@...iv.linux.org.uk>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Kees Cook <keescook@...omium.org>,
        Arnd Bergmann <arnd@...db.de>, Ingo Molnar <mingo@...nel.org>,
        Ard Biesheuvel <ard.biesheuvel@...aro.org>,
        Andy Lutomirski <luto@...nel.org>,
        Nicolas Pitre <nicolas.pitre@...aro.org>,
        Petr Mladek <pmladek@...e.com>, Helge Deller <deller@....de>,
        Rik van Riel <riel@...hat.com>,
        Thomas Garnier <thgarnie@...gle.com>,
        Parav Pandit <pandit.parav@...il.com>,
        "seokhoon . yoon" <iamyooon@...il.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Dave Hansen <dave.hansen@...el.com>,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     josh@...htriplett.org, brkkurek192@...il.com, conorcurry@...il.com,
        fanofbond138@...il.com, Brian Ashworth <bosrsf04@...il.com>
Subject: [PATCH 1/3] fs: Makes functions used by pivot_root accessible

From: Brian Ashworth <bosrsf04@...il.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@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ