From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751560AbdBYAWn (ORCPT ); Fri, 24 Feb 2017 19:22:43 -0500 Received: from mail-qk0-f196.google.com ([209.85.220.196]:35356 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751372AbdBYAWj (ORCPT ); Fri, 24 Feb 2017 19:22:39 -0500 From: bosrsf04@gmail.com To: Alexander Viro , Andrew Morton , Kees Cook , Arnd Bergmann , Ingo Molnar , Ard Biesheuvel , Andy Lutomirski , Nicolas Pitre , Petr Mladek , Helge Deller , Rik van Riel , Thomas Garnier , Parav Pandit , "seokhoon . yoon" , Thomas Gleixner , Dave Hansen , 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 Subject: [PATCH 1/3] fs: Makes functions used by pivot_root accessible Date: Fri, 24 Feb 2017 19:21:49 -0500 Message-Id: X-Mailer: git-send-email 2.11.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brian Ashworth 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 --- 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 #include #include +#include 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