Skip to content

Commit c12dada

Browse files
rhvgoyalgregkh
authored andcommitted
ovl: Copy up underlying inode's ->i_mode to overlay inode
commit 07a2daab49c549a37b5b744cbebb6e3f445f12bc upstream. 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 <vgoyal@redhat.com> Reported-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Fixes: 4bacc9c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e9a2ce2 commit c12dada

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

fs/overlayfs/inode.c

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

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

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

fs/overlayfs/overlayfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ static inline void ovl_copyattr(struct inode *from, struct inode *to)
181181
{
182182
to->i_uid = from->i_uid;
183183
to->i_gid = from->i_gid;
184+
to->i_mode = from->i_mode;
184185
}
185186

186187
/* dir.c */

0 commit comments

Comments
 (0)