Skip to content

Commit 07a2daa

Browse files
rhvgoyalMiklos Szeredi
authored andcommitted
ovl: Copy up underlying inode's ->i_mode to overlay inode
Right now when a new overlay inode is created, we initialize overlay inode's ->i_mode from underlying inode ->i_mode but we retain only file type bits (S_IFMT) and discard permission bits. This patch changes it and retains permission bits too. This should allow overlay to do permission checks on overlay inode itself in task context. [SzM] It also fixes clearing suid/sgid bits on write. Signed-off-by: Vivek Goyal <[email protected]> Reported-by: Eryu Guan <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]> Fixes: 4bacc9c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay") Cc: <[email protected]>
1 parent b99c2d9 commit 07a2daa

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

fs/overlayfs/inode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,11 @@ struct inode *ovl_new_inode(struct super_block *sb, umode_t mode,
413413
if (!inode)
414414
return NULL;
415415

416-
mode &= S_IFMT;
417-
418416
inode->i_ino = get_next_ino();
419417
inode->i_mode = mode;
420418
inode->i_flags |= S_NOATIME | S_NOCMTIME;
421419

420+
mode &= S_IFMT;
422421
switch (mode) {
423422
case S_IFDIR:
424423
inode->i_private = oe;

fs/overlayfs/overlayfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ static inline void ovl_copyattr(struct inode *from, struct inode *to)
187187
{
188188
to->i_uid = from->i_uid;
189189
to->i_gid = from->i_gid;
190+
to->i_mode = from->i_mode;
190191
}
191192

192193
/* dir.c */

0 commit comments

Comments
 (0)