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: 9943011 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E7BFF604D5 for ; Fri, 8 Sep 2017 00:12:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF7A327C0B for ; Fri, 8 Sep 2017 00:12:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D43EC27D16; Fri, 8 Sep 2017 00:12:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, SUSPICIOUS_RECIPS, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77D8127DA4 for ; Fri, 8 Sep 2017 00:12:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753101AbdIHAMk (ORCPT ); Thu, 7 Sep 2017 20:12:40 -0400 Received: from mail-pg0-f47.google.com ([74.125.83.47]:34016 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753055AbdIHAMi (ORCPT ); Thu, 7 Sep 2017 20:12:38 -0400 Received: by mail-pg0-f47.google.com with SMTP id q68so2123125pgq.1 for ; Thu, 07 Sep 2017 17:12:38 -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=q0V6sU4YFMp1f1FweZJjEH3W7rDH8ggcM6EGJSslDc8ewtHAXxuVyGu8tW9R+mkhGo OskjWps6lNxwvXAB5saU+iqEJNf64rhy1vE3brpiav2YWKWYjv9g2q3s0MdgF/J3EeKL 0hD2pomsJ2k56ibsSjRDX8S1mkl7i3lgDGSxAizXfyH3Dxoxui0cYgLc3xJwQTBJD9Uu lsaxtaLX7vCw7CaZXrwIZ/JSp/DqjxTuTfGr2WRucZLBqb+j9CT1eIk7Sprt4NXcr5nf TdkGZU4T5X76gXidW2eRnKNeVpI/aFo7HL/yStEk7wqiH+VPJoh20b44krLz6Wrtb9EJ ioiQ== X-Gm-Message-State: AHPjjUjvFUs6MZTs6jNx5ERpHcl0sREUAcz5KpXKa15GIdP/YAW8xBWd 2hEik7aJInogSb8JHyQufQ== 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-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)