Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932882AbcJUJQr (ORCPT ); Fri, 21 Oct 2016 05:16:47 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46690 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932823AbcJUJQm (ORCPT ); Fri, 21 Oct 2016 05:16:42 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Whitney , Theodore Tso Subject: [PATCH 4.4 16/25] ext4: enforce online defrag restriction for encrypted files Date: Fri, 21 Oct 2016 11:16:07 +0200 Message-Id: <20161021091414.071618516@linuxfoundation.org> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161021091413.053290730@linuxfoundation.org> References: <20161021091413.053290730@linuxfoundation.org> User-Agent: quilt/0.64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1322 Lines: 42 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Whitney commit 14fbd4aa613bd5110556c281799ce36dc6f3ba97 upstream. Online defragging of encrypted files is not currently implemented. However, the move extent ioctl can still return successfully when called. For example, this occurs when xfstest ext4/020 is run on an encrypted file system, resulting in a corrupted test file and a corresponding test failure. Until the proper functionality is implemented, fail the move extent ioctl if either the original or donor file is encrypted. Signed-off-by: Eric Whitney Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/move_extent.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c @@ -598,6 +598,13 @@ ext4_move_extents(struct file *o_filp, s return -EOPNOTSUPP; } + if (ext4_encrypted_inode(orig_inode) || + ext4_encrypted_inode(donor_inode)) { + ext4_msg(orig_inode->i_sb, KERN_ERR, + "Online defrag not supported for encrypted files"); + return -EOPNOTSUPP; + } + /* Protect orig and donor inodes against a truncate */ lock_two_nondirectories(orig_inode, donor_inode);