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: 816591 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DDLroncX"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="P3T1FqAY"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Gw51A00T"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xyFsy5D93z9sNr for ; Thu, 21 Sep 2017 09:13:42 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=6jRGkRb+W8UrvKTC1ZurWG1M7qa8gApSEcpeJZSBYZU=; b=DDLroncXRM9HKFp4/MRHT78W6g z8tGJlkJkGEA4PWWyTHXki06Zyw833KlcNggJJhuKzSB9gOLdCUu9aLOQOkpWHdWNU8tm7Nl3LIbG SRArVS4QiQTsLL1ZbtaW6ZvjRVnDk0H7LPAPgaTzxZwz/3tSeetDk3QIqk/RuKu6zb/GXIj6a5H2z QbkpgcPmcq9iei0QDD9IxkMgpW8fuLWbFaR7nXkRpdKHEX72BVhyG1atGomT6ElrjY8oFH0h0WsDC dIduUVyJeqUhRlMmnjyReFj1vbZf6TYooLjVGxnpAYcRT5sEwT099QRXrnIjvWVk8STIRLryus3Pa PYhwF83w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1duoBT-0007tq-JK; Wed, 20 Sep 2017 23:13:35 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1duoAm-0006j8-8o for linux-mtd@bombadil.infradead.org; Wed, 20 Sep 2017 23:12:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3FtVWARjoE+b9wG70tcBL/JSR+i6aA4xoM6RIVGGK1c=; b=P3T1FqAYvSGTND5TzHmoM/E39 13QzGwhb2RUGpdPlqNavS0/OQtfQ/g1tAele6BO9X95xAhq38EN6xUfpzjAi6vn7BoTgbrAO3E1IS mkM68kef1Wfjk8MjICiLRQ1OUdOOk55SqbRrkWMef7gSaOrvC/zDpCw4Xj/oznlHpSVv6YpGfnJLS cd1OLBYmD6b/KFzfji5SlQLicBzBOUqs7Q3yP7xwE/WKFgn4/n2eN3aQyfwrRizrxJa073GTJV/Qz u6RmTbZntLra1RAI0sfJWUAZupHTsDJ6cnFuCoPLtdi9lDKPy2M6CijPiiyW/Kb7Kd/H8p+d5X5Z0 oluYYUdxw==; Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dunmJ-0004t9-E7 for linux-mtd@lists.infradead.org; Wed, 20 Sep 2017 22:47:37 +0000 Received: by mail-pf0-x242.google.com with SMTP id e69so1716587pfg.4 for ; Wed, 20 Sep 2017 15:47:17 -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=Rq9wuTdo2QtkabmYdVeyMPAhO9T6Yh5ypXGpCViMApn54UHSjx98j7FC/vG7lrJ2us 9ilOdQfxjc/OUFeDb+xJ4J98cYw2yWajYol74ylDYkkE0iV34mCD7PylG4qrvc2zAMlW 8CzqznXHN3ofUkxGgrQ14Lp4sw1UVkVqGYx8RHKGh38X+3myBtm1IfPSx9C07QwmLwWR y/Rvo353igIlBg/lmtPf9EGmACZoOczrT6LqRMLnghgP7Sf/ESZefvr2YMsvfOD+vdSR gKocOIloJ5fl6n4A0ifpGc+OqOVKmrFFTwQKDtGhD7LziqXUatbCwJNhnmnwAUJg5dKJ 7paA== X-Gm-Message-State: AHPjjUgFIic9/B+GUdDuvLUj5gmcpc4Ce1BkcCAlBQaYDQ+g2FCStaTW FP/M6BTWEyn4QDs6UeMg4VA= 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170920_234735_776829_5CF63646 X-CRM114-Status: GOOD ( 12.47 ) X-Spam-Score: -1.8 (-) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-1.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c00:0:0:0:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (ebiggers3[at]gmail.com) 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ebiggers3[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Theodore Y . Ts'o" , Eric Biggers , Michael Halcrow , linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, Jaegeuk Kim , linux-ext4@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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);