linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers3@gmail.com>
To: linux-mtd@lists.infradead.org, Richard Weinberger <richard@nod.at>
Cc: linux-fscrypt@vger.kernel.org,
	Artem Bityutskiy <dedekind1@gmail.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Eric Biggers <ebiggers@google.com>
Subject: [PATCH v2 3/5] ubifs: switch to fscrypt_prepare_rename()
Date: Wed, 29 Nov 2017 12:43:15 -0800	[thread overview]
Message-ID: <20171129204317.91205-4-ebiggers3@gmail.com> (raw)
In-Reply-To: <20171129204317.91205-1-ebiggers3@gmail.com>

From: Eric Biggers <ebiggers@google.com>

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 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);
 
-- 
2.15.0.531.g2ccb3012c9-goog

  parent reply	other threads:[~2017-11-29 20:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-29 20:43 [PATCH v2 0/5] ubifs: switch to new fscrypt helper functions Eric Biggers
2017-11-29 20:43 ` [PATCH v2 1/5] ubifs: switch to fscrypt_file_open() Eric Biggers
2017-11-29 20:43 ` [PATCH v2 2/5] ubifs: switch to fscrypt_prepare_link() Eric Biggers
2017-11-29 20:43 ` Eric Biggers [this message]
2017-11-29 20:43 ` [PATCH v2 4/5] ubifs: switch to fscrypt_prepare_lookup() Eric Biggers
2017-11-29 20:43 ` [PATCH v2 5/5] ubifs: switch to fscrypt_prepare_setattr() Eric Biggers
2018-01-05 18:37 ` [PATCH v2 0/5] ubifs: switch to new fscrypt helper functions Eric Biggers
2018-01-05 22:11   ` Richard Weinberger
2018-01-17 21:12     ` Richard Weinberger
2018-01-17 21:23       ` Eric Biggers
2018-01-17 21:36         ` Richard Weinberger
2018-01-17 23:44           ` Eric Biggers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171129204317.91205-4-ebiggers3@gmail.com \
    --to=ebiggers3@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=dedekind1@gmail.com \
    --cc=ebiggers@google.com \
    --cc=linux-fscrypt@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).