Skip to contentSkip to conversation

ovl: fix lock in ovl_llseek()

PATCH New Amir Goldstein 1 participant 1 message Mar 2, 2020 Overlay filesystem

lore
Share & tools
lore

Amir Goldstein

author maintainer
#0 lore raw

PATCH 1/1 ovl: fix lock in ovl_llseek()

ovl_inode_lock() is interruptible. When inode_lock() in ovl_llseek() was replaced with ovl_inode_lock(), we did not add a check for error.

Fix this by making ovl_inode_lock() uninterruptible and change the existing call sites to use an _interruptible variant.

Reported-by [email protected]
Fixes b1f9d3858f72 ("ovl: use ovl_inode_lock in ovl_llseek()")
---
 fs/overlayfs/overlayfs.h | 7 ++++++-
 fs/overlayfs/util.c      | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)
fs/overlayfs/overlayfs.h +6 -1
index 3623d28aa4fa..3d3f2b8bdae5 100644
@@ -318,7 +318,12 @@ static inline unsigned int ovl_xino_bits(struct super_block *sb)
 	return ovl_same_dev(sb) ? OVL_FS(sb)->xino_mode : 0;
 }
 
-static inline int ovl_inode_lock(struct inode *inode)
+static inline void ovl_inode_lock(struct inode *inode)
+{
+	mutex_lock(&OVL_I(inode)->lock);
+}
+
+static inline int ovl_inode_lock_interruptible(struct inode *inode)
 {
 	return mutex_lock_interruptible(&OVL_I(inode)->lock);
 }
fs/overlayfs/util.c +2 -2
index ea005085803f..042f7eb4f7f4 100644
@@ -509,7 +509,7 @@ int ovl_copy_up_start(struct dentry *dentry, int flags)
 	struct inode *inode = d_inode(dentry);
 	int err;
 
-	err = ovl_inode_lock(inode);
+	err = ovl_inode_lock_interruptible(inode);
 	if (!err && ovl_already_copied_up_locked(dentry, flags)) {
 		err = 1; /* Already copied up */
 		ovl_inode_unlock(inode);
@@ -764,7 +764,7 @@ int ovl_nlink_start(struct dentry *dentry)
 			return err;
 	}
 
-	err = ovl_inode_lock(inode);
+	err = ovl_inode_lock_interruptible(inode);
 	if (err)
 		return err;
 
Signature · 1 line
2.17.1