Skip to content

Commit 64ee480

Browse files
Michael HalcrowLinus Torvalds
authored andcommitted
eCryptfs: ecryptfs_setattr() bugfix
There is another bug recently introduced into the ecryptfs_setattr() function in 2.6.22. eCryptfs will attempt to treat special files like regular eCryptfs files on chmod, chown, and so forth. This leads to a NULL pointer dereference. This patch validates that the file is a regular file before proceeding with operations related to the inode's crypt_stat. Thanks to Ryusuke Konishi for finding this bug and suggesting the fix. Signed-off-by: Michael Halcrow <mhalcrow@us.ibm.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 39ef01e commit 64ee480

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎fs/ecryptfs/inode.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,9 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
902902
mutex_lock(&crypt_stat->cs_mutex);
903903
if (S_ISDIR(dentry->d_inode->i_mode))
904904
crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
905-
else if (!(crypt_stat->flags & ECRYPTFS_POLICY_APPLIED)
906-
|| !(crypt_stat->flags & ECRYPTFS_KEY_VALID)) {
905+
else if (S_ISREG(dentry->d_inode->i_mode)
906+
&& (!(crypt_stat->flags & ECRYPTFS_POLICY_APPLIED)
907+
|| !(crypt_stat->flags & ECRYPTFS_KEY_VALID))) {
907908
struct vfsmount *lower_mnt;
908909
struct file *lower_file = NULL;
909910
struct ecryptfs_mount_crypt_stat *mount_crypt_stat;

0 commit comments

Comments
 (0)