stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Patch "fscrypto: only allow setting encryption policy on directories" has been added to the 4.7-stable tree
@ 2016-09-12 15:18 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2016-09-12 15:18 UTC (permalink / raw)
  To: ebiggers, gregkh, tytso; +Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    fscrypto: only allow setting encryption policy on directories

to the 4.7-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     fscrypto-only-allow-setting-encryption-policy-on-directories.patch
and it can be found in the queue-4.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From 002ced4be6429918800ce3e41d5cbc2d7c01822c Mon Sep 17 00:00:00 2001
From: Eric Biggers <ebiggers@google.com>
Date: Thu, 8 Sep 2016 11:36:39 -0700
Subject: fscrypto: only allow setting encryption policy on directories

From: Eric Biggers <ebiggers@google.com>

commit 002ced4be6429918800ce3e41d5cbc2d7c01822c upstream.

The FS_IOC_SET_ENCRYPTION_POLICY ioctl allowed setting an encryption
policy on nondirectory files.  This was unintentional, and in the case
of nonempty regular files did not behave as expected because existing
data was not actually encrypted by the ioctl.

In the case of ext4, the user could also trigger filesystem errors in
->empty_dir(), e.g. due to mismatched "directory" checksums when the
kernel incorrectly tried to interpret a regular file as a directory.

This bug affected ext4 with kernels v4.8-rc1 or later and f2fs with
kernels v4.6 and later.  It appears that older kernels only permitted
directories and that the check was accidentally lost during the
refactoring to share the file encryption code between ext4 and f2fs.

This patch restores the !S_ISDIR() check that was present in older
kernels.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/crypto/policy.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -102,6 +102,8 @@ int fscrypt_process_policy(struct inode
 		return -EINVAL;
 
 	if (!inode_has_encryption_context(inode)) {
+		if (!S_ISDIR(inode->i_mode))
+			return -EINVAL;
 		if (!inode->i_sb->s_cop->empty_dir)
 			return -EOPNOTSUPP;
 		if (!inode->i_sb->s_cop->empty_dir(inode))


Patches currently in stable-queue which might be from ebiggers@google.com are

queue-4.7/fscrypto-add-authorization-check-for-setting-encryption-policy.patch
queue-4.7/fscrypto-only-allow-setting-encryption-policy-on-directories.patch

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

only message in thread, other threads:[~2016-09-12 15:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-12 15:18 Patch "fscrypto: only allow setting encryption policy on directories" has been added to the 4.7-stable tree gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).