From: Andy Whitcroft <apw@canonical.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: viro@ZenIV.linux.org.uk, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
nbd@openwrt.org, neilb@suse.de, hramrach@centrum.cz,
jordipujolp@gmail.com, mszeredi@suse.cz
Subject: Re: [PATCH 0/7] overlay filesystem v9
Date: Thu, 19 May 2011 19:04:28 +0100 [thread overview]
Message-ID: <20110519180428.GI3702@shadowen.org> (raw)
In-Reply-To: <20110519163709.GH3702@shadowen.org>
On Thu, May 19, 2011 at 05:37:09PM +0100, Andy Whitcroft wrote:
> Now I am nothing like a filesystems expert but looking at what other
> filesystems do I think the patch below is sufficient, but certainly it
> needs some sanity checking. At least it fixes all the issues I see here.
Doh. Below.
-apw
>From 8bab7242155e614d357e23132cc86964822300d0 Mon Sep 17 00:00:00 2001
From: Andy Whitcroft <apw@canonical.com>
Date: Thu, 19 May 2011 12:43:59 +0100
Subject: [PATCH 1/1] ovl: ensure overlayfs inodes have correct ownerships
Overlayfs builds internal inodes representing the intersection between
the upper and lower directories. However these inodes do not inherit the
ownership of the underlying inodes, this is transparent in the normal case
as most operations apply to the real backing inodes. However the LSM
hooks commonly are passed these inodes and may make erroneous decisions
based on the carried credentials.
Fix up the permissions in any new inode to either match the intended
ownership of the directory for new files, or the underlying file for
existing files.
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
fs/overlayfs/dir.c | 15 +++++++++------
fs/overlayfs/super.c | 2 ++
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index e1c09c4..f0a672f 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -268,8 +268,8 @@ static int ovl_dir_getattr(struct vfsmount *mnt, struct dentry *dentry,
return 0;
}
-static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev,
- const char *link)
+static int ovl_create_object(struct inode *dir, struct dentry *dentry, int mode,
+ dev_t rdev, const char *link)
{
int err;
struct dentry *newdentry;
@@ -284,6 +284,7 @@ static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev,
inode = ovl_new_inode(dentry->d_sb, mode, dentry->d_fsdata);
if (!inode)
goto out;
+ inode_init_owner(inode, dir, mode);
err = ovl_copy_up(dentry->d_parent);
if (err)
@@ -325,24 +326,26 @@ out:
static int ovl_create(struct inode *dir, struct dentry *dentry, int mode,
struct nameidata *nd)
{
- return ovl_create_object(dentry, (mode & 07777) | S_IFREG, 0, NULL);
+ return ovl_create_object(dir, dentry,
+ (mode & 07777) | S_IFREG, 0, NULL);
}
static int ovl_mkdir(struct inode *dir, struct dentry *dentry, int mode)
{
- return ovl_create_object(dentry, (mode & 07777) | S_IFDIR, 0, NULL);
+ return ovl_create_object(dir, dentry,
+ (mode & 07777) | S_IFDIR, 0, NULL);
}
static int ovl_mknod(struct inode *dir, struct dentry *dentry, int mode,
dev_t rdev)
{
- return ovl_create_object(dentry, mode, rdev, NULL);
+ return ovl_create_object(dir, dentry, mode, rdev, NULL);
}
static int ovl_symlink(struct inode *dir, struct dentry *dentry,
const char *link)
{
- return ovl_create_object(dentry, S_IFLNK, 0, link);
+ return ovl_create_object(dir, dentry, S_IFLNK, 0, link);
}
static int ovl_do_remove(struct dentry *dentry, bool is_dir)
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index a9a09a6..e6b3af5 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -321,6 +321,8 @@ int ovl_do_lookup(struct dentry *dentry)
realdentry = upperdentry ? upperdentry : lowerdentry;
err = -ENOMEM;
inode = ovl_new_inode(dentry->d_sb, realdentry->d_inode->i_mode, oe);
+ inode->i_uid = realdentry->d_inode->i_uid;
+ inode->i_gid = realdentry->d_inode->i_gid;
if (!inode)
goto out_dput;
}
--
1.7.4.1
next prev parent reply other threads:[~2011-05-19 18:04 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-17 12:30 [PATCH 0/7] overlay filesystem v9 Miklos Szeredi
2011-05-17 12:30 ` [PATCH 1/7] tmpfs: implement generic xattr support Miklos Szeredi
2011-05-17 12:30 ` [PATCH 2/7] vfs: add i_op->open() Miklos Szeredi
2011-05-17 12:30 ` [PATCH 3/7] vfs: export do_splice_direct() to modules Miklos Szeredi
2011-05-17 12:30 ` [PATCH 4/7] vfs: introduce clone_private_mount() Miklos Szeredi
2011-05-17 12:30 ` [PATCH 5/7] overlay filesystem Miklos Szeredi
2011-05-17 12:30 ` [PATCH 6/7] overlayfs: add statfs support Miklos Szeredi
2011-05-17 12:30 ` [PATCH 7/7] overlay: overlay filesystem documentation Miklos Szeredi
2011-05-17 15:13 ` [PATCH 0/7] overlay filesystem v9 Michal Suchanek
2011-05-19 16:37 ` Andy Whitcroft
2011-05-19 17:44 ` Miklos Szeredi
2011-05-19 18:05 ` Andy Whitcroft
2011-05-19 22:12 ` NeilBrown
2011-05-20 8:18 ` Miklos Szeredi
2011-05-20 12:43 ` Andy Whitcroft
2011-05-19 19:04 ` John Stoffel
2011-05-19 20:30 ` Andy Whitcroft
2011-05-19 20:34 ` John Stoffel
2011-05-19 18:04 ` Andy Whitcroft [this message]
2011-05-20 8:56 ` Michal Suchanek
[not found] ` <103d3f78e2d3478d8bb93f5dda3a4a08@HUBCAS1.cs.stonybrook.edu>
2011-05-20 5:39 ` [PATCH 5/7] overlay filesystem (inode.c bad error path) Erez Zadok
2011-05-20 5:55 ` Erez Zadok
2011-05-20 14:25 ` Miklos Szeredi
[not found] ` <efad20cd4c664cd78e153b0fda2de605@HUBCAS2.cs.stonybrook.edu>
2011-05-21 5:15 ` Erez Zadok
2011-05-20 8:54 ` Miklos Szeredi
2011-05-20 14:17 ` Miklos Szeredi
[not found] ` <7dcd9c4e62864bc6aae66f5a4e3f3752@HUBCAS1.cs.stonybrook.edu>
2011-05-21 4:26 ` Erez Zadok
2011-05-23 8:57 ` Miklos Szeredi
[not found] ` <b11ac28b818740a8b3f619e756735e41@HUBCAS2.cs.stonybrook.edu>
2011-05-24 1:02 ` Erez Zadok
2011-05-20 5:58 ` [PATCH 5/7] overlay filesystem (negative dentries cause OOPS on NULL inode) Erez Zadok
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=20110519180428.GI3702@shadowen.org \
--to=apw@canonical.com \
--cc=akpm@linux-foundation.org \
--cc=hramrach@centrum.cz \
--cc=jordipujolp@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=mszeredi@suse.cz \
--cc=nbd@openwrt.org \
--cc=neilb@suse.de \
--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;
as well as URLs for NNTP newsgroup(s).