]>
Commit | Line | Data |
---|---|---|
68184a5a JR |
1 | From 3d5a6482fd89423b94d8bb3a0a303f0b40bb4279 Mon Sep 17 00:00:00 2001 |
2 | From: Andy Whitcroft <apw@canonical.com> | |
3 | Date: Thu, 9 Aug 2012 16:47:21 +0100 | |
4 | Subject: [PATCH 13/13] overlayfs: copy up i_uid/i_gid from the underlying | |
5 | inode | |
6 | Patch-mainline: not yet | |
7 | ||
8 | YAMA et al rely on on i_uid/i_gid to be populated in order to perform | |
9 | their checks. While these really cannot be guarenteed as the underlying | |
10 | filesystem may not even have the concept, they are expected to be filled | |
11 | when possible. To quote Al Viro: | |
12 | ||
13 | "Ideally, yes, we'd want to have ->i_uid used only by fs-specific | |
14 | code and helpers used by that fs (including those that are | |
15 | implicit defaults). [...] In practice we have enough places | |
16 | where uid/gid is used directly to make setting them practically | |
17 | a requirement - places like /proc/<pid>/ can get away with | |
18 | not doing that, but only because shitloads of syscalls are | |
19 | not allowed on those anyway, permissions or no permissions. | |
20 | In anything general-purpose you really need to set it." | |
21 | ||
22 | Copy up the underlying filesystem information into the overlayfs inode | |
23 | when we create it. | |
24 | ||
25 | Buglink: http://bugs.launchpad.net/bugs/944386 | |
26 | Signed-off-by: Andy Whitcroft <apw@canonical.com> | |
27 | Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> | |
28 | --- | |
29 | fs/overlayfs/dir.c | 2 ++ | |
30 | fs/overlayfs/inode.c | 2 ++ | |
31 | fs/overlayfs/overlayfs.h | 6 ++++++ | |
32 | fs/overlayfs/super.c | 1 + | |
33 | 4 files changed, 11 insertions(+) | |
34 | ||
35 | Index: linux-3.6-rc7-master/fs/overlayfs/dir.c | |
36 | =================================================================== | |
37 | --- linux-3.6-rc7-master.orig/fs/overlayfs/dir.c 2012-09-28 13:37:04.000000000 +0200 | |
38 | +++ linux-3.6-rc7-master/fs/overlayfs/dir.c 2012-09-28 13:37:10.000000000 +0200 | |
39 | @@ -304,6 +304,7 @@ static int ovl_create_object(struct dent | |
40 | } | |
41 | } | |
42 | ovl_dentry_update(dentry, newdentry); | |
43 | + ovl_copyattr(newdentry->d_inode, inode); | |
44 | d_instantiate(dentry, inode); | |
45 | inode = NULL; | |
46 | newdentry = NULL; | |
47 | @@ -446,6 +447,7 @@ static int ovl_link(struct dentry *old, | |
48 | new->d_fsdata); | |
49 | if (!newinode) | |
50 | goto link_fail; | |
51 | + ovl_copyattr(upperdir->d_inode, newinode); | |
52 | ||
53 | ovl_dentry_version_inc(new->d_parent); | |
54 | ovl_dentry_update(new, newdentry); | |
55 | Index: linux-3.6-rc7-master/fs/overlayfs/inode.c | |
56 | =================================================================== | |
57 | --- linux-3.6-rc7-master.orig/fs/overlayfs/inode.c 2012-09-28 13:37:08.000000000 +0200 | |
58 | +++ linux-3.6-rc7-master/fs/overlayfs/inode.c 2012-09-28 13:37:10.000000000 +0200 | |
59 | @@ -31,6 +31,8 @@ int ovl_setattr(struct dentry *dentry, s | |
60 | ||
61 | mutex_lock(&upperdentry->d_inode->i_mutex); | |
62 | err = notify_change(upperdentry, attr); | |
63 | + if (!err) | |
64 | + ovl_copyattr(upperdentry->d_inode, dentry->d_inode); | |
65 | mutex_unlock(&upperdentry->d_inode->i_mutex); | |
66 | ||
67 | return err; | |
68 | Index: linux-3.6-rc7-master/fs/overlayfs/overlayfs.h | |
69 | =================================================================== | |
70 | --- linux-3.6-rc7-master.orig/fs/overlayfs/overlayfs.h 2012-09-28 13:36:53.000000000 +0200 | |
71 | +++ linux-3.6-rc7-master/fs/overlayfs/overlayfs.h 2012-09-28 13:37:10.000000000 +0200 | |
72 | @@ -56,6 +56,12 @@ int ovl_removexattr(struct dentry *dentr | |
73 | ||
74 | struct inode *ovl_new_inode(struct super_block *sb, umode_t mode, | |
75 | struct ovl_entry *oe); | |
76 | +static inline void ovl_copyattr(struct inode *from, struct inode *to) | |
77 | +{ | |
78 | + to->i_uid = from->i_uid; | |
79 | + to->i_gid = from->i_gid; | |
80 | +} | |
81 | + | |
82 | /* dir.c */ | |
83 | extern const struct inode_operations ovl_dir_inode_operations; | |
84 | ||
85 | Index: linux-3.6-rc7-master/fs/overlayfs/super.c | |
86 | =================================================================== | |
87 | --- linux-3.6-rc7-master.orig/fs/overlayfs/super.c 2012-09-28 13:37:00.000000000 +0200 | |
88 | +++ linux-3.6-rc7-master/fs/overlayfs/super.c 2012-09-28 13:37:10.000000000 +0200 | |
89 | @@ -347,6 +347,7 @@ static int ovl_do_lookup(struct dentry * | |
90 | oe); | |
91 | if (!inode) | |
92 | goto out_dput; | |
93 | + ovl_copyattr(realdentry->d_inode, inode); | |
94 | } | |
95 | ||
96 | if (upperdentry) |