mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] eCryptfs: Protect crypt_stat->flags in ecryptfs_open()
       [not found] <20080402150736.288c2f91.akpm@linux-foundation.org>
@ 2008-04-22 15:41 ` Michael Halcrow
  0 siblings, 0 replies; only message in thread
From: Michael Halcrow @ 2008-04-22 15:41 UTC (permalink / raw)
  To: Andrew Morton; +Cc: LKML, Al Viro

Al Viro wrote:
> 	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().

Signed-off-by: Michael Halcrow <mhalcrow@us.ibm.com>
---
 fs/ecryptfs/file.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index 2b8f5ed..2258b8f 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -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;
 	}
-- 
1.5.1.6


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-22 15:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20080402150736.288c2f91.akpm@linux-foundation.org>
2008-04-22 15:41 ` [PATCH] eCryptfs: Protect crypt_stat->flags in ecryptfs_open() Michael Halcrow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®