From patchwork Fri Sep 8 00:12:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Halcrow X-Patchwork-Id: 811267 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="X+8QJKUG"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xpHnv3sPlz9sMN for ; Fri, 8 Sep 2017 10:12:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752752AbdIHAMd (ORCPT ); Thu, 7 Sep 2017 20:12:33 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:34573 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752549AbdIHAMc (ORCPT ); Thu, 7 Sep 2017 20:12:32 -0400 Received: by mail-pf0-f178.google.com with SMTP id e1so1928028pfk.1 for ; Thu, 07 Sep 2017 17:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p/JV/GCGMlQrRMcB4xRDJuCDYFD95LtSDYEi9esBWvE=; b=X+8QJKUGY7vzJmz1iJqV7GgxdVNqS9/WTdbYgoM0ccLCQ8WCb22kSXO2NIEoqeWp1V biRx0eMrH2fcv59BcrJEBptKQ6VuNa1ffqzmdbHdoRNgvcU3FP8GHtAz/tU3JSuH4bog y5G6a9uEpSaija1ypRMP1gFX0B/K7uUX8FRAGpAZemGkFBMIRh2Hhl9/oBSxRCvtNZB0 AYlk0WsvRwkH2QKr57dF34YQkFjrkhSMD2gD+DzdE+Tlmwong3syLfRatU5W5LNELlLz 7Mrk3Z01AXfJvr7TZrF9F2QvwAIYykMHw/bY7r2yoO0faf5hu5BT/dEaIp4EJzMzqEKF DBNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=p/JV/GCGMlQrRMcB4xRDJuCDYFD95LtSDYEi9esBWvE=; b=haDEUxqcLNe0Jz2tAIu7Xg8r7NKmbjHxIV4r1Hs3wfIXsWyIINXP2t7jC9WkL9TbxF KAvmtPDucoKBLb2jPxvKkfTqcyFuIQYqtapeb/rk5jCNnwxYafJhJaWTduhRWKtFM9P/ w171cf7izWrbZaf9KurXC+S9+6aWNtTq+ZYhjHmIrHfsFzjUzf+8+WFQMV5gyEerB7fz 46h0d5Y0pYffjKlOm7c6Jx8A1AJEj25XjFQWKB1Gv9YAr9L2v1CUdJg5Lfjr/yoU8a3I UcHRtOqzoy6p/bkRzisw/NKSkA71EPuS951fpm7rdPV+zfgu8cI6e/PZ1u3vdnMWPths ZRnA== X-Gm-Message-State: AHPjjUiBmPjRnti41YWXKvDO4q7WFqrCqF2sqLL0wwgyoWp2ssRWcEgE BfsJoakClINKcbp49X0Phg== X-Google-Smtp-Source: ADKCNb7gVRvszoGixNODZzDTX4Rg+1Ssu6aS33fYta90PO6l576fJYafIE3T8CDNkWqEoCl4XzYMoA== X-Received: by 10.98.236.81 with SMTP id k78mr1227570pfh.336.1504829551886; Thu, 07 Sep 2017 17:12:31 -0700 (PDT) Received: from mhalcrow-linux.kir.corp.google.com ([100.66.175.61]) by smtp.gmail.com with ESMTPSA id d25sm1007805pfb.1.2017.09.07.17.12.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Sep 2017 17:12:31 -0700 (PDT) From: Michael Halcrow To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, tytso@mit.edu, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org Subject: [PATCH 1/3] ext4 crypto: Return -EXDEV for link, rename, and cross-rename between incompat contexts Date: Thu, 7 Sep 2017 17:12:02 -0700 Message-Id: <20170908001204.18174-2-mhalcrow@google.com> X-Mailer: git-send-email 2.14.1.581.gf28d330327-goog In-Reply-To: <20170908001204.18174-1-mhalcrow@google.com> References: <20170908001204.18174-1-mhalcrow@google.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Gives user space the opportunity to fall back to copy-and-delete. Signed-off-by: Michael Halcrow --- fs/ext4/namei.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index c1cf020d1889..3c493bc4273d 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -3223,7 +3223,7 @@ static int ext4_link(struct dentry *old_dentry, return -EMLINK; if (ext4_encrypted_inode(dir) && !fscrypt_has_permitted_context(dir, inode)) - return -EPERM; + return -EXDEV; if ((ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT)) && (!projid_eq(EXT4_I(dir)->i_projid, @@ -3552,7 +3552,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, if ((old.dir != new.dir) && ext4_encrypted_inode(new.dir) && !fscrypt_has_permitted_context(new.dir, old.inode)) { - retval = -EPERM; + retval = -EXDEV; goto end_rename; } @@ -3732,7 +3732,7 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry, (old_dir != new_dir) && (!fscrypt_has_permitted_context(new_dir, old.inode) || !fscrypt_has_permitted_context(old_dir, new.inode))) - return -EPERM; + return -EXDEV; if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT) && !projid_eq(EXT4_I(new_dir)->i_projid, From patchwork Fri Sep 8 00:12:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Halcrow X-Patchwork-Id: 811268 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="Ice0QMtg"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xpHp02RF9z9s81 for ; Fri, 8 Sep 2017 10:12:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752948AbdIHAMh (ORCPT ); Thu, 7 Sep 2017 20:12:37 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:36272 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752606AbdIHAMf (ORCPT ); Thu, 7 Sep 2017 20:12:35 -0400 Received: by mail-pg0-f46.google.com with SMTP id m9so2116957pgd.3 for ; Thu, 07 Sep 2017 17:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VzkLSlJeRYCLVLtHBOnDTxgB9u1PqKbInpwTOtVP8ew=; b=Ice0QMtgOPM3VaTp8Vrr2EfumHDDeKVnQCPZKM+z5v1EPtyaytZX/2fg1wehZzUuz8 BPO6+BseSzrqBbJuc/4/GAc2Bi/YNF1G6jaAU0ycfCOho/7TjQvKfIMtLHcDpYjXQ4cj 9+7dTFrtUmFoa1S9H6BkPUXMpcieioONW+UaT0P4bFgYAW5n8kWItpTfS3Tjm60njQRt RV3WV9Kn0o+tjlHFo16o9XhyQ7XrBrXcpLetzGEfzbCBhXNyH8WNY70ST6EmFAi5OqnF AlzumS3TqwfrOIdnJ9lfDUWhAOnKgJrL1YcvWORyRdzn7aIUprEortQK9uKqvyciiNeI DALA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VzkLSlJeRYCLVLtHBOnDTxgB9u1PqKbInpwTOtVP8ew=; b=PrJCX6r52jB1y0DJ2xuZhJwTd1vAyNWq2XZveOnFsESSu4QNDNG5oeSfg9BoZQ1lqI 5epQOWdBXgczhuc1q8S3NL3sJe18jEp6W/NKEXi2UjWKKokx6zHnNX2O3jZT1ZwiLdng PiL+g+oqq+EM+aInAGpkPnUsQQJRLQUKTnx9vDNksizfvUyzh5FN1Rk5TIhcuHleSiU+ fzuMYEMJkW7EeHv/4tvvAIYI+AVRMa75v4bRZ+f2WJmpN03hMH4bE927ADtq964vQTF+ VTJr3S33QUk+FMJXokz82y84SuK6CxaOG3kAM+p24I66UBYF1d8GE5vAvIs4tIArmKnp MX0w== X-Gm-Message-State: AHPjjUhqkyOomfHbcgVao2ihCotwo7T2GzUZBaSIvSX14YY3CyYzw+NF kpBaXz3n3BGCpfKz X-Google-Smtp-Source: ADKCNb77OBNGz8iqrYgB9/+r49OFHEniG2dVLtNf2S2/yzWYKxQ7LZeRnjSt29F8cd6gPZLVWnb7kA== X-Received: by 10.98.15.208 with SMTP id 77mr1189693pfp.318.1504829555043; Thu, 07 Sep 2017 17:12:35 -0700 (PDT) Received: from mhalcrow-linux.kir.corp.google.com ([100.66.175.61]) by smtp.gmail.com with ESMTPSA id d25sm1007805pfb.1.2017.09.07.17.12.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Sep 2017 17:12:34 -0700 (PDT) From: Michael Halcrow To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, tytso@mit.edu, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org Subject: [PATCH 2/3] F2FS crypto: Return -EXDEV for link, rename, and cross-rename between incompat contexts Date: Thu, 7 Sep 2017 17:12:03 -0700 Message-Id: <20170908001204.18174-3-mhalcrow@google.com> X-Mailer: git-send-email 2.14.1.581.gf28d330327-goog In-Reply-To: <20170908001204.18174-1-mhalcrow@google.com> References: <20170908001204.18174-1-mhalcrow@google.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Gives user space the opportunity to fall back to copy-and-delete. Signed-off-by: Michael Halcrow --- fs/f2fs/namei.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 760d85223c81..689c671cf8b8 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -202,7 +202,7 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir, if (f2fs_encrypted_inode(dir) && !fscrypt_has_permitted_context(dir, inode)) - return -EPERM; + return -EXDEV; err = dquot_initialize(dir); if (err) @@ -720,7 +720,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, if ((old_dir != new_dir) && f2fs_encrypted_inode(new_dir) && !fscrypt_has_permitted_context(new_dir, old_inode)) { - err = -EPERM; + err = -EXDEV; goto out; } @@ -910,7 +910,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, (old_dir != new_dir) && (!fscrypt_has_permitted_context(new_dir, old_inode) || !fscrypt_has_permitted_context(old_dir, new_inode))) - return -EPERM; + return -EXDEV; err = dquot_initialize(old_dir); if (err) From patchwork Fri Sep 8 00:12:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Halcrow X-Patchwork-Id: 811269 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="QZ5fy9eq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xpHp21lq6z9s81 for ; Fri, 8 Sep 2017 10:12:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753242AbdIHAMk (ORCPT ); Thu, 7 Sep 2017 20:12:40 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:38223 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752549AbdIHAMh (ORCPT ); Thu, 7 Sep 2017 20:12:37 -0400 Received: by mail-pg0-f54.google.com with SMTP id v66so2087025pgb.5 for ; Thu, 07 Sep 2017 17:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qDjywoq7Vkn7rFJB7qZ7l3QEG4VNF8mMs4cBtXwCfq0=; b=QZ5fy9eq6+/nFtZjgrqpDue+frA+q8wasI1uuQtSVhKDkm3q+h7Se8c/L+IVVAfvQl JZWUEmeCL+VR8QvOx35cYG1cyhB1ZEs80FSrgi7hkcvf/vgmMQUb4bxTkeUJ9Tsyqe7E LJhyTGujzQ7KWNar5SNKdXU2qmTwNbtNmeTkj+Mk3S4Gks5SOOnvafxpLVXJoRUH+FyS Bs1ZFhq9WHgbD+rpFUZXgoggg+hsnbza5j/BQ2wo5Y3lIrcNsntkuSkQiwUr4l7BxM/D 3JpV3CVMfGloOGxTrSf5WAOn5xWTVDQ0L53PRx7WwBFre8cnPFyLoh+56kSt9lw7swUJ FnlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qDjywoq7Vkn7rFJB7qZ7l3QEG4VNF8mMs4cBtXwCfq0=; b=A83uXq8TNICIYt+YzAtO0LZ9+e5LswS+kNncegbUgxyVYDxYWI/Jvg+fdIWYxJyJd4 s3aGU0weJcFBBYonHTETE49q4eV4QgC0bcB48JJ+TecZgbqUKnJ7wjVVWJ0PCZ4dyRHA NitjelHwPKu0SYwqK6yNpEwp2sU6nggU14pG7pcqSTqa7DeNOHVDLBtaEomtMRsQWkOi /FmbrLeilADAor0TY0F/NQ0fwOd/OEQh6C4IQOTgbyCrHRS/fJut4NJhhYSAQDMlSvGv Z7GsxRDGBomiBvQi8MFtTurDWwzbWi60ZIswykK4kxNp3Se5bqYY7CIKPYuvWG5Jm9cj OTiw== X-Gm-Message-State: AHPjjUgs+CP0HtlVyqKj/JmbZCmGh3qd7izpXhykCBSgY+5hkuy+D9r+ sYnU68oHFnTRpl1K2mZqOw== X-Google-Smtp-Source: ADKCNb4QfNMNxfw8TbCVeDqp1WNCcaEoHB4z7idGyPhInLTE1pHpNfqRl1X7WnoHEnb506ZiXvxB/A== X-Received: by 10.98.248.71 with SMTP id c7mr1158757pfm.129.1504829557244; Thu, 07 Sep 2017 17:12:37 -0700 (PDT) Received: from mhalcrow-linux.kir.corp.google.com ([100.66.175.61]) by smtp.gmail.com with ESMTPSA id d25sm1007805pfb.1.2017.09.07.17.12.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Sep 2017 17:12:36 -0700 (PDT) From: Michael Halcrow To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, tytso@mit.edu, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org Subject: [PATCH 3/3] UBIFS crypto: Return -EXDEV for link, rename, and cross-rename between incompat contexts Date: Thu, 7 Sep 2017 17:12:04 -0700 Message-Id: <20170908001204.18174-4-mhalcrow@google.com> X-Mailer: git-send-email 2.14.1.581.gf28d330327-goog In-Reply-To: <20170908001204.18174-1-mhalcrow@google.com> References: <20170908001204.18174-1-mhalcrow@google.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Gives user space the opportunity to fall back to copy-and-delete. Signed-off-by: Michael Halcrow --- fs/ubifs/dir.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 417fe0b29f23..6c5753a2f79f 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -745,7 +745,7 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir, if (ubifs_crypt_is_encrypted(dir) && !fscrypt_has_permitted_context(dir, inode)) - return -EPERM; + return -EXDEV; err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); if (err) @@ -1356,7 +1356,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, if (old_dir != new_dir) { if (ubifs_crypt_is_encrypted(new_dir) && !fscrypt_has_permitted_context(new_dir, old_inode)) - return -EPERM; + return -EXDEV; } if (unlink && is_dir) { @@ -1578,7 +1578,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry, (old_dir != new_dir) && (!fscrypt_has_permitted_context(new_dir, fst_inode) || !fscrypt_has_permitted_context(old_dir, snd_inode))) - return -EPERM; + return -EXDEV; err = fscrypt_setup_filename(old_dir, &old_dentry->d_name, 0, &fst_nm); if (err)