f2fs: don't bother checking for encryption key in ->write_iter()
authorEric Biggers <ebiggers@google.com>
Tue, 23 May 2017 00:39:45 +0000 (17:39 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 24 May 2017 04:11:08 +0000 (21:11 -0700)
Since only an open file can be written to, and we only allow open()ing
an encrypted file when its key is available, there is no need to check
for the key again before permitting each ->write_iter().

This code was also broken in that it wouldn't actually have failed if
the key was in fact unavailable.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: David Gstir <david@sigma-star.at>
Acked-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c

index 30fbb4ce6a735ff3858ddc74cd20845305cdd3f6..65915b4ce14beaf826274b85b983f23410d101ad 100644 (file)
@@ -2340,11 +2340,6 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
        struct blk_plug plug;
        ssize_t ret;
 
-       if (f2fs_encrypted_inode(inode) &&
-                               !fscrypt_has_encryption_key(inode) &&
-                               fscrypt_get_encryption_info(inode))
-               return -EACCES;
-
        inode_lock(inode);
        ret = generic_write_checks(iocb, from);
        if (ret > 0) {