Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1100897ybk; Wed, 13 May 2020 23:55:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1FJ8U0E8gIoSUI3uqNq/IXE/TUNDLbZ8vCFJoCnhhojBHY8pKIlkgXJctV56r2uIVs9aQ X-Received: by 2002:a17:906:3517:: with SMTP id r23mr2502087eja.304.1589439318467; Wed, 13 May 2020 23:55:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589439318; cv=none; d=google.com; s=arc-20160816; b=ByXJbBkOApsLqsDmYLqbCrRnxrrj1SBJT+OxkVCN2mqUNOKL1gttgfKnEacJhTXSP0 kZppXWSvqY8qSvdkU17UPdUro4g5A6e0b8v+0y2nFDPPorkxptxCsIj262cIvVtv6fsi EP23O7q1gzaPqnsE7FSEWAgexojTcK2lqZI6ghjkjI6pWyaCEVmX9VO8XUBynZDWb1oP Shok0CnAo0vEXYkmdrBuWf2n1rF/4hCKldNAmQO0eAqM2oi+SWweKdavyrKFfqI8arZk vYpsCb4o0lJflug3AGWo3m3L3qSUj+lArWx2XADjRp3DgiLL8xYUJHZWu57DMlWb88Vj HWOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=E6TVooozycS5WwWm3wUq70SgjAsckGXejKwRoUTxuts=; b=mxjDOfuNcF3qVoibb2Puzc/6HKpO9NKcutSWJQXh3XdpEUGDzMgPzHUK36XPpSZGGl BHr6Sr4zrlUFRnYNAFEah8gsSOIg9pok7N/6Adnwk/HLelULKKqfEQxp8PVcaXlB8VOj 2Ob2YxiJg6u59GL6AbkuasmTDpSmMrO6hG96/OcJHTUbrKjSVI0gqOU9M+Uc4ICezIMf yGJWezn1vb9MYtq6+slBJKQCwVq9AucrhQbUl6rBJ43cToCJEu6BiyN+y00RRcBz3AMR gEQpyaXGMTDkeQFIheMUzBsG0uPyPfm8xEXyGmAIAQAujEKJLnQ1yG9QfoVgY6TBOxTe ZrJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz18si1410209ejb.112.2020.05.13.23.54.55; Wed, 13 May 2020 23:55:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726471AbgENGxw (ORCPT + 99 others); Thu, 14 May 2020 02:53:52 -0400 Received: from mga06.intel.com ([134.134.136.31]:7482 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbgENGxX (ORCPT ); Thu, 14 May 2020 02:53:23 -0400 IronPort-SDR: 4J+UcognWBo98ZPZ7VvY3rUHW9DSY4unv4x6beOHgS2MBy9N39Mp9ZzE3gaUNbPd0dFWpJnZSF WIbyRu0N+ojA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2020 23:53:21 -0700 IronPort-SDR: 3Euo1TnrL+gFXMsHy56+Q4zzGyDWO93rM3nwbmA082quBS0INMjQ4fn7vQ7Wt4vY9x3qGtlBkD cwPNvI+09B6A== X-IronPort-AV: E=Sophos;i="5.73,390,1583222400"; d="scan'208";a="341515269" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2020 23:53:21 -0700 From: ira.weiny@intel.com To: linux-ext4@vger.kernel.org, Andreas Dilger , "Theodore Y. Ts'o" , Jan Kara Cc: Ira Weiny , Al Viro , Dan Williams , Dave Chinner , Christoph Hellwig , Jeff Moyer , "Darrick J. Wong" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V1 3/9] fs/ext4: Disallow encryption if inode is DAX Date: Wed, 13 May 2020 23:53:09 -0700 Message-Id: <20200514065316.2500078-4-ira.weiny@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200514065316.2500078-1-ira.weiny@intel.com> References: <20200514065316.2500078-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Ira Weiny Encryption and DAX are incompatible. Changing the DAX mode due to a change in Encryption mode is wrong without a corresponding address_space_operations update. Make the 2 options mutually exclusive by returning an error if DAX was set first. Furthermore, clarify the documentation of the exclusivity and how that will work. Signed-off-by: Ira Weiny --- Changes: remove WARN_ON_ONCE Add documentation to the encrypt doc WRT DAX --- Documentation/filesystems/fscrypt.rst | 4 +++- fs/ext4/super.c | 10 +--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Documentation/filesystems/fscrypt.rst b/Documentation/filesystems/fscrypt.rst index aa072112cfff..1475b8d52fef 100644 --- a/Documentation/filesystems/fscrypt.rst +++ b/Documentation/filesystems/fscrypt.rst @@ -1038,7 +1038,9 @@ astute users may notice some differences in behavior: - The ext4 filesystem does not support data journaling with encrypted regular files. It will fall back to ordered data mode instead. -- DAX (Direct Access) is not supported on encrypted files. +- DAX (Direct Access) is not supported on encrypted files. Attempts to enable + DAX on an encrypted file will fail. Mount options will _not_ enable DAX on + encrypted files. - The st_size of an encrypted symlink will not necessarily give the length of the symlink target as required by POSIX. It will actually diff --git a/fs/ext4/super.c b/fs/ext4/super.c index bf5fcb477f66..9873ab27e3fa 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1320,7 +1320,7 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, if (inode->i_ino == EXT4_ROOT_INO) return -EPERM; - if (WARN_ON_ONCE(IS_DAX(inode) && i_size_read(inode))) + if (IS_DAX(inode)) return -EINVAL; res = ext4_convert_inline_data(inode); @@ -1344,10 +1344,6 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, ext4_set_inode_flag(inode, EXT4_INODE_ENCRYPT); ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA); - /* - * Update inode->i_flags - S_ENCRYPTED will be enabled, - * S_DAX may be disabled - */ ext4_set_inode_flags(inode); } return res; @@ -1371,10 +1367,6 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, ctx, len, 0); if (!res) { ext4_set_inode_flag(inode, EXT4_INODE_ENCRYPT); - /* - * Update inode->i_flags - S_ENCRYPTED will be enabled, - * S_DAX may be disabled - */ ext4_set_inode_flags(inode); res = ext4_mark_inode_dirty(handle, inode); if (res) -- 2.25.1