From patchwork Wed Sep 20 22:46:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 9962785 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 72EE36056D for ; Wed, 20 Sep 2017 22:47:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6385129274 for ; Wed, 20 Sep 2017 22:47:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 582092927A; Wed, 20 Sep 2017 22:47:46 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 EFEC029158 for ; Wed, 20 Sep 2017 22:47:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752043AbdITWra (ORCPT ); Wed, 20 Sep 2017 18:47:30 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33246 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752025AbdITWrR (ORCPT ); Wed, 20 Sep 2017 18:47:17 -0400 Received: by mail-pf0-f195.google.com with SMTP id h4so1728716pfk.0; Wed, 20 Sep 2017 15:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3FtVWARjoE+b9wG70tcBL/JSR+i6aA4xoM6RIVGGK1c=; b=Gw51A00TXsjiFcRTh564XmjTuqqFIgHNOTs38pBmqhh2zO5eoZnxiKkMarGWUjk9eS rBzqr8tLcNJltqglcqiLfeGvlqs7AFNxwC+yIOc3dIxYjvRvuOaBxe3cbT2khSJq4UjS P/cWQXjQhi7jku0ha3rmEBKzcekCocEt+TGaqAmZrOpLWHDgMx+tUv2gaBDLIERrYmXx Xcal2RDOLO/hfTai9i5rj2GxrlOkqAl1cA6SRW6dQp7iGD+hx1r2PO3jpJSRw5xWmRt8 rbQbXJAnP1z2+4TnhI/y1j0iwAnG+09cK/4pYchBOI7oce57Uj8PBTmk6km3mj/1o961 M7Wg== 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=3FtVWARjoE+b9wG70tcBL/JSR+i6aA4xoM6RIVGGK1c=; b=Zeps1eLu9V+jq7uFMFFzv61sGiTYdyTGwqgdN3u2QUlgPQrnkXf8h6ePXOmcJqq/8E n/r5IONx5Nj8xxp3cV4eFJ6tSG+aLNahzRibAks+KKVPCtcMrQnU6sULOT+oMP3WRX5n AR166vy8yeyl428Awng4f9Avx03izRREZuSgn64Plny2cN3cLEfoh+Z2P0fuHR7QMV+7 8M6UaryE9vujZO1rQs2RiobA5WYOfFi0NkomvGmnL1nau2r1Lw4wZTMSt3m+e0oRS0lQ dnnUvZwTDJ3RyLXA0IVHrlJZ2HJCO1ND0NvUB3+jgz51avW75pM5DQUocNBrQAI2AuCC mfjQ== X-Gm-Message-State: AHPjjUjN1Q04qwZ4s17HmMwKAR9veNarFhqaLSsFr5W4SVW3DZf06Qkw wABLb8fKdls5SsFbdsAxonH/WyscCXc= X-Google-Smtp-Source: AOwi7QBVFAr72WiXMUTnMq2EjjAxE/u45V4Psp3fIt86wyN/Nn7kMSJfPRxK0sxY2bOkyHo59SZW3Q== X-Received: by 10.84.210.45 with SMTP id z42mr3567308plh.178.1505947636051; Wed, 20 Sep 2017 15:47:16 -0700 (PDT) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.174.81]) by smtp.gmail.com with ESMTPSA id j2sm6249pgn.26.2017.09.20.15.47.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 15:47:15 -0700 (PDT) From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, "Theodore Y . Ts'o" , Jaegeuk Kim , Michael Halcrow , Eric Biggers Subject: [PATCH 23/25] ubifs: switch to fscrypt_prepare_rename() Date: Wed, 20 Sep 2017 15:46:03 -0700 Message-Id: <20170920224605.22030-24-ebiggers3@gmail.com> X-Mailer: git-send-email 2.14.1.821.g8fa685d3b7-goog In-Reply-To: <20170920224605.22030-1-ebiggers3@gmail.com> References: <20170920224605.22030-1-ebiggers3@gmail.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 From: Eric Biggers Signed-off-by: Eric Biggers --- fs/ubifs/dir.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 09e6c56b11bc..7bf847d79b4a 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -1353,12 +1353,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, if (unlink) ubifs_assert(inode_is_locked(new_inode)); - if (old_dir != new_dir) { - if (ubifs_crypt_is_encrypted(new_dir) && - !fscrypt_has_permitted_context(new_dir, old_inode)) - return -EPERM; - } - if (unlink && is_dir) { err = ubifs_check_dir_empty(new_inode); if (err) @@ -1573,13 +1567,6 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry, ubifs_assert(fst_inode && snd_inode); - if ((ubifs_crypt_is_encrypted(old_dir) || - ubifs_crypt_is_encrypted(new_dir)) && - (old_dir != new_dir) && - (!fscrypt_has_permitted_context(new_dir, fst_inode) || - !fscrypt_has_permitted_context(old_dir, snd_inode))) - return -EPERM; - err = fscrypt_setup_filename(old_dir, &old_dentry->d_name, 0, &fst_nm); if (err) return err; @@ -1624,12 +1611,19 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags) { + int err; + if (flags & ~(RENAME_NOREPLACE | RENAME_WHITEOUT | RENAME_EXCHANGE)) return -EINVAL; ubifs_assert(inode_is_locked(old_dir)); ubifs_assert(inode_is_locked(new_dir)); + err = fscrypt_prepare_rename(old_dir, old_dentry, new_dir, new_dentry, + flags); + if (err) + return err; + if (flags & RENAME_EXCHANGE) return ubifs_xrename(old_dir, old_dentry, new_dir, new_dentry);