From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:56244 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750929AbdKFJNg (ORCPT ); Mon, 6 Nov 2017 04:13:36 -0500 Subject: Patch "vfs: open() with O_CREAT should not create inodes with unknown ids" has been added to the 4.9-stable tree To: seth.forshee@canonical.com, alexander.levin@verizon.com, ebiederm@xmission.com, gregkh@linuxfoundation.org Cc: , From: Date: Mon, 06 Nov 2017 10:11:54 +0100 Message-ID: <1509959514222245@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled vfs: open() with O_CREAT should not create inodes with unknown ids to the 4.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: vfs-open-with-o_creat-should-not-create-inodes-with-unknown-ids.patch and it can be found in the queue-4.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From foo@baz Mon Nov 6 10:07:35 CET 2017 From: Seth Forshee Date: Sat, 7 Oct 2017 22:36:55 +0000 Subject: vfs: open() with O_CREAT should not create inodes with unknown ids From: Seth Forshee [ Upstream commit 1328c727004d432bbdfba0ffa02a166df04c7305 ] may_create() rejects creation of inodes with ids which lack a mapping into s_user_ns. However for O_CREAT may_o_create() is is used instead. Add a similar check there. Fixes: 036d523641c6 ("vfs: Don't create inodes with a uid or gid unknown to the vfs") Signed-off-by: Seth Forshee Signed-off-by: "Eric W. Biederman" Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/namei.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/fs/namei.c +++ b/fs/namei.c @@ -2971,10 +2971,16 @@ static inline int open_to_namei_flags(in static int may_o_create(const struct path *dir, struct dentry *dentry, umode_t mode) { + struct user_namespace *s_user_ns; int error = security_path_mknod(dir, dentry, mode, 0); if (error) return error; + s_user_ns = dir->dentry->d_sb->s_user_ns; + if (!kuid_has_mapping(s_user_ns, current_fsuid()) || + !kgid_has_mapping(s_user_ns, current_fsgid())) + return -EOVERFLOW; + error = inode_permission(dir->dentry->d_inode, MAY_WRITE | MAY_EXEC); if (error) return error; Patches currently in stable-queue which might be from seth.forshee@canonical.com are queue-4.9/vfs-open-with-o_creat-should-not-create-inodes-with-unknown-ids.patch