Skip to content

Commit 39a25b2

Browse files
rhvgoyalMiklos Szeredi
authored andcommitted
ovl: define ->get_acl() for overlay inodes
Now we are planning to do DAC permission checks on overlay inode itself. And to make it work, we will need to make sure we can get acls from underlying inode. So define ->get_acl() for overlay inodes and this in turn calls into underlying filesystem to get acls, if any. Signed-off-by: Vivek Goyal <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 72e4848 commit 39a25b2

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

fs/overlayfs/dir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,4 +921,5 @@ const struct inode_operations ovl_dir_inode_operations = {
921921
.getxattr = ovl_getxattr,
922922
.listxattr = ovl_listxattr,
923923
.removexattr = ovl_removexattr,
924+
.get_acl = ovl_get_acl,
924925
};

fs/overlayfs/inode.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,22 @@ int ovl_removexattr(struct dentry *dentry, const char *name)
310310
return err;
311311
}
312312

313+
struct posix_acl *ovl_get_acl(struct inode *inode, int type)
314+
{
315+
struct inode *realinode = ovl_inode_real(inode);
316+
317+
if (!realinode)
318+
return ERR_PTR(-ENOENT);
319+
320+
if (!IS_POSIXACL(realinode))
321+
return NULL;
322+
323+
if (!realinode->i_op->get_acl)
324+
return NULL;
325+
326+
return realinode->i_op->get_acl(realinode, type);
327+
}
328+
313329
static bool ovl_open_need_copy_up(int flags, enum ovl_path_type type,
314330
struct dentry *realdentry)
315331
{
@@ -354,6 +370,7 @@ static const struct inode_operations ovl_file_inode_operations = {
354370
.getxattr = ovl_getxattr,
355371
.listxattr = ovl_listxattr,
356372
.removexattr = ovl_removexattr,
373+
.get_acl = ovl_get_acl,
357374
};
358375

359376
static const struct inode_operations ovl_symlink_inode_operations = {

fs/overlayfs/overlayfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ struct dentry *ovl_dentry_upper(struct dentry *dentry);
142142
struct dentry *ovl_dentry_lower(struct dentry *dentry);
143143
struct dentry *ovl_dentry_real(struct dentry *dentry);
144144
struct dentry *ovl_entry_real(struct ovl_entry *oe, bool *is_upper);
145+
struct inode *ovl_inode_real(struct inode *inode);
145146
struct vfsmount *ovl_entry_mnt_real(struct ovl_entry *oe, struct inode *inode,
146147
bool is_upper);
147148
struct ovl_dir_cache *ovl_dir_cache(struct dentry *dentry);
@@ -179,6 +180,7 @@ ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode,
179180
const char *name, void *value, size_t size);
180181
ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size);
181182
int ovl_removexattr(struct dentry *dentry, const char *name);
183+
struct posix_acl *ovl_get_acl(struct inode *inode, int type);
182184
int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags);
183185

184186
struct inode *ovl_new_inode(struct super_block *sb, umode_t mode,

fs/overlayfs/super.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ struct dentry *ovl_entry_real(struct ovl_entry *oe, bool *is_upper)
159159
return realdentry;
160160
}
161161

162+
struct inode *ovl_inode_real(struct inode *inode)
163+
{
164+
bool tmp;
165+
166+
return d_inode(ovl_entry_real(inode->i_private, &tmp));
167+
}
168+
162169
struct vfsmount *ovl_entry_mnt_real(struct ovl_entry *oe, struct inode *inode,
163170
bool is_upper)
164171
{
@@ -1172,6 +1179,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
11721179
sb->s_op = &ovl_super_operations;
11731180
sb->s_root = root_dentry;
11741181
sb->s_fs_info = ufs;
1182+
sb->s_flags |= MS_POSIXACL;
11751183

11761184
return 0;
11771185

0 commit comments

Comments
 (0)