diff options
Diffstat (limited to 'fs/overlayfs/util.c')
-rw-r--r-- | fs/overlayfs/util.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 117794582f9f..b9b239fa5cfd 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c | |||
@@ -430,7 +430,7 @@ void ovl_inuse_unlock(struct dentry *dentry) | |||
430 | } | 430 | } |
431 | } | 431 | } |
432 | 432 | ||
433 | /* Called must hold OVL_I(inode)->oi_lock */ | 433 | /* Caller must hold OVL_I(inode)->lock */ |
434 | static void ovl_cleanup_index(struct dentry *dentry) | 434 | static void ovl_cleanup_index(struct dentry *dentry) |
435 | { | 435 | { |
436 | struct inode *dir = ovl_indexdir(dentry->d_sb)->d_inode; | 436 | struct inode *dir = ovl_indexdir(dentry->d_sb)->d_inode; |
@@ -469,6 +469,9 @@ static void ovl_cleanup_index(struct dentry *dentry) | |||
469 | err = PTR_ERR(index); | 469 | err = PTR_ERR(index); |
470 | if (!IS_ERR(index)) | 470 | if (!IS_ERR(index)) |
471 | err = ovl_cleanup(dir, index); | 471 | err = ovl_cleanup(dir, index); |
472 | else | ||
473 | index = NULL; | ||
474 | |||
472 | inode_unlock(dir); | 475 | inode_unlock(dir); |
473 | if (err) | 476 | if (err) |
474 | goto fail; | 477 | goto fail; |
@@ -557,3 +560,22 @@ void ovl_nlink_end(struct dentry *dentry, bool locked) | |||
557 | mutex_unlock(&OVL_I(d_inode(dentry))->lock); | 560 | mutex_unlock(&OVL_I(d_inode(dentry))->lock); |
558 | } | 561 | } |
559 | } | 562 | } |
563 | |||
564 | int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir) | ||
565 | { | ||
566 | /* Workdir should not be the same as upperdir */ | ||
567 | if (workdir == upperdir) | ||
568 | goto err; | ||
569 | |||
570 | /* Workdir should not be subdir of upperdir and vice versa */ | ||
571 | if (lock_rename(workdir, upperdir) != NULL) | ||
572 | goto err_unlock; | ||
573 | |||
574 | return 0; | ||
575 | |||
576 | err_unlock: | ||
577 | unlock_rename(workdir, upperdir); | ||
578 | err: | ||
579 | pr_err("overlayfs: failed to lock workdir+upperdir\n"); | ||
580 | return -EIO; | ||
581 | } | ||