From patchwork Wed Sep 20 22:45:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 9962783 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 605866056A 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 5260C29276 for ; Wed, 20 Sep 2017 22:47:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4719629278; 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=unavailable 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 7F03229277 for ; Wed, 20 Sep 2017 22:47:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751982AbdITWrN (ORCPT ); Wed, 20 Sep 2017 18:47:13 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36399 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751976AbdITWrL (ORCPT ); Wed, 20 Sep 2017 18:47:11 -0400 Received: by mail-pf0-f195.google.com with SMTP id f84so1721716pfj.3; Wed, 20 Sep 2017 15:47:11 -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=gxgNvumxJG5UwVuKFZNruBWfCDgQCgm7TqKy9BGQaxs=; b=cpblON3++MUNGT0cpXapFnrlewX2SNUVM5d981MO0wzGIJKN3S4TU/V90fP0RMJ1U6 H3TDtidEC/+woPb0RYNcbWwH3aOloJBnYjxAUA64AthED0QZMkJWet/+CeL4Ysw8v6Yr xYVLu6xJ12h4IyVV1ywyZ5pEPoC/6YQbraOPE8HXX9uyH9PH2ZZ++8Dr3//6gzk+jvo+ 8SYIqDJLwxDuBYwuzs6WSModh4cDj6qDytHMghU1WFB+MWKE1518BXgf2oyo69XsCz3P uSuGif6dW8nm0OW9kowaCvVuAptI6eUTd8lWi8ZBs7E1QRV308ZT4dyb4BWsRylOTq/m 5RaQ== 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=gxgNvumxJG5UwVuKFZNruBWfCDgQCgm7TqKy9BGQaxs=; b=NmzNt+tAVhBl1mGKMVGnpS9p3og17WEfG5GPvGT2NEnXbQBasGa9lxl3b9rOReBFyo JqYy70tT0dNq7AB1+c4bG/VBfAO40Yl0b8PVsNxb+u0cohF65SGo6oSNab8idUgtqYsu GscKaGbAaDzRISO76ZWibcAHcbpl8GNyVMcXMSFOkuXzNPG9m1E1fLp/ZqTtRFGaiPcI gE4vxKPuBVgNJqRJfinkW+9xtzujRTSlFvXzoavvc1W3fFESvYxB5Cyp1RK0pjztNL1q Zw4afnmueW6vzHSMRRtGr30+lEnD7xHrq/0Su8zTvmHvIgJn2UR37u1jaXOTpob+Uwlh 8khA== X-Gm-Message-State: AHPjjUhrbR1SuclvtpXvIzpDu/TqIAzBZls/fRhZF8HxppSC0yQrTrCJ tSEEKvt0uPq/fQqqEOYZ58sWsd2rLSI= X-Google-Smtp-Source: AOwi7QCdxAMGKHk3stdDkAPZbeyac5aMI6I43R1YGzPIaBN0tg1mvnqe5aup5OkFBsFQpRYEnszSpw== X-Received: by 10.98.135.194 with SMTP id i185mr3619483pfe.330.1505947630513; Wed, 20 Sep 2017 15:47:10 -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.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 15:47:10 -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 18/25] f2fs: switch to fscrypt_prepare_rename() Date: Wed, 20 Sep 2017 15:45:58 -0700 Message-Id: <20170920224605.22030-19-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/f2fs/namei.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index cf4e4294e450..80bcf2185fd8 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -742,18 +742,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, bool is_old_inline = f2fs_has_inline_dentry(old_dir); int err = -ENOENT; - if ((f2fs_encrypted_inode(old_dir) && - !fscrypt_has_encryption_key(old_dir)) || - (f2fs_encrypted_inode(new_dir) && - !fscrypt_has_encryption_key(new_dir))) - return -ENOKEY; - - if ((old_dir != new_dir) && f2fs_encrypted_inode(new_dir) && - !fscrypt_has_permitted_context(new_dir, old_inode)) { - err = -EPERM; - goto out; - } - if (is_inode_flag_set(new_dir, FI_PROJ_INHERIT) && (!projid_eq(F2FS_I(new_dir)->i_projid, F2FS_I(old_dentry->d_inode)->i_projid))) @@ -935,18 +923,6 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, int old_nlink = 0, new_nlink = 0; int err = -ENOENT; - if ((f2fs_encrypted_inode(old_dir) && - !fscrypt_has_encryption_key(old_dir)) || - (f2fs_encrypted_inode(new_dir) && - !fscrypt_has_encryption_key(new_dir))) - return -ENOKEY; - - if ((f2fs_encrypted_inode(old_dir) || f2fs_encrypted_inode(new_dir)) && - (old_dir != new_dir) && - (!fscrypt_has_permitted_context(new_dir, old_inode) || - !fscrypt_has_permitted_context(old_dir, new_inode))) - return -EPERM; - if ((is_inode_flag_set(new_dir, FI_PROJ_INHERIT) && !projid_eq(F2FS_I(new_dir)->i_projid, F2FS_I(old_dentry->d_inode)->i_projid)) || @@ -1086,9 +1062,16 @@ static int f2fs_rename2(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_EXCHANGE | RENAME_WHITEOUT)) return -EINVAL; + err = fscrypt_prepare_rename(old_dir, old_dentry, new_dir, new_dentry, + flags); + if (err) + return err; + if (flags & RENAME_EXCHANGE) { return f2fs_cross_rename(old_dir, old_dentry, new_dir, new_dentry);