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 PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Tue, 12 Jan 2021 23:00:57 +0100 From: Christian Brauner <christian.brauner@...ntu.com> To: Alexander Viro <viro@...iv.linux.org.uk>, Christoph Hellwig <hch@...radead.org>, linux-fsdevel@...r.kernel.org Cc: John Johansen <john.johansen@...onical.com>, James Morris <jmorris@...ei.org>, Mimi Zohar <zohar@...ux.ibm.com>, Dmitry Kasatkin <dmitry.kasatkin@...il.com>, Stephen Smalley <stephen.smalley.work@...il.com>, Casey Schaufler <casey@...aufler-ca.com>, Arnd Bergmann <arnd@...db.de>, Andreas Dilger <adilger.kernel@...ger.ca>, OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>, Geoffrey Thomas <geofft@...reload.com>, Mrunal Patel <mpatel@...hat.com>, Josh Triplett <josh@...htriplett.org>, Andy Lutomirski <luto@...nel.org>, Theodore Tso <tytso@....edu>, Alban Crequy <alban@...volk.io>, Tycho Andersen <tycho@...ho.ws>, David Howells <dhowells@...hat.com>, James Bottomley <James.Bottomley@...senpartnership.com>, Seth Forshee <seth.forshee@...onical.com>, Stéphane Graber <stgraber@...ntu.com>, Linus Torvalds <torvalds@...ux-foundation.org>, Aleksa Sarai <cyphar@...har.com>, Lennart Poettering <lennart@...ttering.net>, "Eric W. Biederman" <ebiederm@...ssion.com>, smbarber@...omium.org, Phil Estes <estesp@...il.com>, Serge Hallyn <serge@...lyn.com>, Kees Cook <keescook@...omium.org>, Todd Kjos <tkjos@...gle.com>, Paul Moore <paul@...l-moore.com>, Jonathan Corbet <corbet@....net>, containers@...ts.linux-foundation.org, linux-security-module@...r.kernel.org, linux-api@...r.kernel.org, linux-ext4@...r.kernel.org, linux-xfs@...r.kernel.org, linux-integrity@...r.kernel.org, selinux@...r.kernel.org, Christian Brauner <christian.brauner@...ntu.com>, Christoph Hellwig <hch@....de> Subject: [PATCH v5 15/42] fs: add file_user_ns() helper Add a simple helper to retrieve the user namespace associated with the vfsmount of a file. Christoph correctly points out that this makes codepaths (e.g. ioctls) way easier to follow that would otherwise dereference via mnt_user_ns(file->f_path.mnt). In order to make file_user_ns() static inline we'd need to include mount.h in either file.h or fs.h which seems undesirable so let's simply not force file_user_ns() to be inline. Cc: David Howells <dhowells@...hat.com> Cc: Al Viro <viro@...iv.linux.org.uk> Cc: linux-fsdevel@...r.kernel.org Suggested-by: Christoph Hellwig <hch@....de> Signed-off-by: Christian Brauner <christian.brauner@...ntu.com> --- /* v2 */ patch not present /* v3 */ patch not present /* v4 */ patch not present /* v5 */ patch introduced base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837 --- fs/namei.c | 6 ++++++ include/linux/fs.h | 1 + 2 files changed, 7 insertions(+) diff --git a/fs/namei.c b/fs/namei.c index cd124e18cec5..d8dee449e92a 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -259,6 +259,12 @@ void putname(struct filename *name) __putname(name); } +struct user_namespace *file_user_ns(struct file *file) +{ + return mnt_user_ns(file->f_path.mnt); +} +EXPORT_SYMBOL(file_user_ns); + /** * check_acl - perform ACL permission checking * @mnt_userns: user namespace of the mount the inode was found from diff --git a/include/linux/fs.h b/include/linux/fs.h index ef993857682b..89e41a821bad 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2585,6 +2585,7 @@ static inline struct file *file_clone_open(struct file *file) return dentry_open(&file->f_path, file->f_flags, file->f_cred); } extern int filp_close(struct file *, fl_owner_t id); +extern struct user_namespace *file_user_ns(struct file *file); extern struct filename *getname_flags(const char __user *, int, int *); extern struct filename *getname(const char __user *); -- 2.30.0
Powered by blists - more mailing lists