Skip to content

Commit f7621b1

Browse files
committed
ovl: protect copying of realinode attributes to ovl inode
ovl_copyattr() may be called concurrently from aio completion context without any lock and that could lead to overlay inode attributes getting permanently out of sync with real inode attributes. Use ovl inode spinlock to protect ovl_copyattr(). Signed-off-by: Amir Goldstein <[email protected]>
1 parent 389a4a4 commit f7621b1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/overlayfs/util.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,7 @@ void ovl_copyattr(struct inode *inode)
14031403
realinode = ovl_i_path_real(inode, &realpath);
14041404
real_idmap = mnt_idmap(realpath.mnt);
14051405

1406+
spin_lock(&inode->i_lock);
14061407
vfsuid = i_uid_into_vfsuid(real_idmap, realinode);
14071408
vfsgid = i_gid_into_vfsgid(real_idmap, realinode);
14081409

@@ -1413,4 +1414,5 @@ void ovl_copyattr(struct inode *inode)
14131414
inode_set_mtime_to_ts(inode, inode_get_mtime(realinode));
14141415
inode_set_ctime_to_ts(inode, inode_get_ctime(realinode));
14151416
i_size_write(inode, i_size_read(realinode));
1417+
spin_unlock(&inode->i_lock);
14161418
}

0 commit comments

Comments
 (0)