Skip to contentSkip to conversation

eCryptfs: Protect crypt_stat->flags in ecryptfs_open()

PATCH New Michael Halcrow 1 participant 1 message Apr 22, 2008 1 message not in the archive Ecrypt file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 eCryptfs: Protect crypt_stat->flags in ecryptfs_open()

Quoted 5 lines · Al Viro

Incidentally, looking at ecryptfs open(), WTF is protecting
crypt_stat->flags? We take crypt_stat->cs_mutex, do nothing but check-and-modify of ->flags under it, then drop and several lines later do crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED); with no ->cs_mutex held...

Make sure crypt_stat->flags is protected with a lock in ecryptfs_open().

---
 fs/ecryptfs/file.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/ecryptfs/file.c +2 -0
index 2b8f5ed..2258b8f 100644
@@ -195,7 +195,9 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
 		file, ecryptfs_inode_to_private(inode)->lower_file);
 	if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) {
 		ecryptfs_printk(KERN_DEBUG, "This is a directory\n");
+		mutex_lock(&crypt_stat->cs_mutex);
 		crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
+		mutex_unlock(&crypt_stat->cs_mutex);
 		rc = 0;
 		goto out;
 	}
Signature · 1 line
1.5.1.6