Skip to content

Commit 5f1c896

Browse files
neilbrownamir73il
authored andcommitted
ovl: use I_MUTEX_PARENT when locking parent in ovl_create_temp()
ovl_create_temp() treats "workdir" as a parent in which it creates an object so it should use I_MUTEX_PARENT. Prior to the commit identified below the lock was taken by the caller which sometimes used I_MUTEX_PARENT and sometimes used I_MUTEX_NORMAL. The use of I_MUTEX_NORMAL was incorrect but unfortunately copied into ovl_create_temp(). Note to backporters: This patch only applies after the last Fixes given below (post v6.16). To fix the bug in v6.7 and later the inode_lock() call in ovl_copy_up_workdir() needs to nest using I_MUTEX_PARENT. Link: https://lore.kernel.org/all/[email protected]/ Cc: [email protected] Reported-by: [email protected] Tested-by: [email protected] Fixes: c63e56a ("ovl: do not open/llseek lower file with upper sb_writers held") Fixes: d2c9955 ("ovl: Call ovl_create_temp() without lock held.") Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Amir Goldstein <[email protected]>
1 parent 8f5ae30 commit 5f1c896

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/overlayfs/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ struct dentry *ovl_create_temp(struct ovl_fs *ofs, struct dentry *workdir,
225225
struct ovl_cattr *attr)
226226
{
227227
struct dentry *ret;
228-
inode_lock(workdir->d_inode);
228+
inode_lock_nested(workdir->d_inode, I_MUTEX_PARENT);
229229
ret = ovl_create_real(ofs, workdir,
230230
ovl_lookup_temp(ofs, workdir), attr);
231231
inode_unlock(workdir->d_inode);

0 commit comments

Comments
 (0)