Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/812696/?format=api
{ "id": 812696, "url": "http://patchwork.ozlabs.org/api/patches/812696/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ext4/patch/20170912050526.7627-4-ross.zwisler@linux.intel.com/", "project": { "id": 8, "url": "http://patchwork.ozlabs.org/api/projects/8/?format=api", "name": "Linux ext4 filesystem development", "link_name": "linux-ext4", "list_id": "linux-ext4.vger.kernel.org", "list_email": "linux-ext4@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170912050526.7627-4-ross.zwisler@linux.intel.com>", "list_archive_url": null, "date": "2017-09-12T05:05:24", "name": "[v2,3/5] ext4: add sanity check for encryption + DAX", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "21c567555bb742d0095d00ca2c31812c5b60b417", "submitter": { "id": 46514, "url": "http://patchwork.ozlabs.org/api/people/46514/?format=api", "name": "Ross Zwisler", "email": "ross.zwisler@linux.intel.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-ext4/patch/20170912050526.7627-4-ross.zwisler@linux.intel.com/mbox/", "series": [ { "id": 2615, "url": "http://patchwork.ozlabs.org/api/series/2615/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ext4/list/?series=2615", "date": "2017-09-12T05:05:23", "name": "ext4: DAX data corruption fixes", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/2615/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/812696/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/812696/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-ext4-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Authentication-Results": "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-ext4-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xrt6g0nvpz9s8J\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 12 Sep 2017 15:06:03 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751354AbdILFFg (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 12 Sep 2017 01:05:36 -0400", "from mga11.intel.com ([192.55.52.93]:12365 \"EHLO mga11.intel.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751311AbdILFFe (ORCPT <rfc822;linux-ext4@vger.kernel.org>);\n\tTue, 12 Sep 2017 01:05:34 -0400", "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t11 Sep 2017 22:05:34 -0700", "from theros.lm.intel.com ([10.232.112.77])\n\tby FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2017 22:05:33 -0700" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.42,381,1500966000\"; d=\"scan'208\";a=\"899352300\"", "From": "Ross Zwisler <ross.zwisler@linux.intel.com>", "To": "\"Theodore Ts'o\" <tytso@mit.edu>, Jan Kara <jack@suse.cz>,\n\tlinux-kernel@vger.kernel.org", "Cc": "Ross Zwisler <ross.zwisler@linux.intel.com>,\n\tAndreas Dilger <adilger.kernel@dilger.ca>,\n\tChristoph Hellwig <hch@lst.de>, Dan Williams <dan.j.williams@intel.com>,\n\tDave Chinner <david@fromorbit.com>, linux-ext4@vger.kernel.org,\n\tlinux-nvdimm@lists.01.org, stable@vger.kernel.org", "Subject": "[PATCH v2 3/5] ext4: add sanity check for encryption + DAX", "Date": "Mon, 11 Sep 2017 23:05:24 -0600", "Message-Id": "<20170912050526.7627-4-ross.zwisler@linux.intel.com>", "X-Mailer": "git-send-email 2.9.5", "In-Reply-To": "<20170912050526.7627-1-ross.zwisler@linux.intel.com>", "References": "<20170912050526.7627-1-ross.zwisler@linux.intel.com>", "Sender": "linux-ext4-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-ext4.vger.kernel.org>", "X-Mailing-List": "linux-ext4@vger.kernel.org" }, "content": "We prevent DAX from being used on inodes which are using ext4's built in\nencryption via a check in ext4_set_inode_flags(). We do have what appears\nto be an unsafe transition of S_DAX in ext4_set_context(), though, where\nS_DAX can get disabled without us doing a proper writeback + invalidate.\n\nThere are also issues with mm-level races when changing the value of S_DAX,\nas well as issues with the VM_MIXEDMAP flag:\n\nhttps://www.spinics.net/lists/linux-xfs/msg09859.html\n\nI actually think we are safe in this case because of the following:\n\n1) You can't encrypt an existing file. Encryption can only be set on an\nempty directory, with new inodes in that directory being created with\nencryption turned on, so I don't think it's possible to turn encryption on\nfor a file that has open DAX mmaps or outstanding I/Os.\n\n2) There is no way to turn encryption off on a given file. Once an inode\nis encrypted, it stays encrypted for the life of that inode, so we don't\nhave to worry about the case where we turn encryption off and S_DAX\nsuddenly turns on.\n\n3) The only way we end up in ext4_set_context() to turn on encryption is\nwhen we are creating a new file in the encrypted directory. This happens\nas part of ext4_create() before the inode has been allowed to do any I/O.\nHere's the call tree:\n\n ext4_create()\n __ext4_new_inode()\n\t ext4_set_inode_flags() // sets S_DAX\n\t fscrypt_inherit_context()\n\t\tfscrypt_get_encryption_info();\n\t\text4_set_context() // sets EXT4_INODE_ENCRYPT, clears S_DAX\n\nSo, I actually think it's safe to transition S_DAX in ext4_set_context()\nwithout any locking, writebacks or invalidations. I've added a\nWARN_ON_ONCE() sanity check to make sure that we are notified if we ever\nencounter a case where we are encrypting an inode that already has data,\nin which case we need to add code to safely transition S_DAX.\n\nSigned-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>\nCC: stable@vger.kernel.org\n---\n fs/ext4/super.c | 3 +++\n 1 file changed, 3 insertions(+)", "diff": "diff --git a/fs/ext4/super.c b/fs/ext4/super.c\nindex 4251e50..c090780 100644\n--- a/fs/ext4/super.c\n+++ b/fs/ext4/super.c\n@@ -1159,6 +1159,9 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len,\n \tif (inode->i_ino == EXT4_ROOT_INO)\n \t\treturn -EPERM;\n \n+\tif (WARN_ON_ONCE(IS_DAX(inode) && i_size_read(inode)))\n+\t\treturn -EINVAL;\n+\n \tres = ext4_convert_inline_data(inode);\n \tif (res)\n \t\treturn res;\n", "prefixes": [ "v2", "3/5" ] }