From patchwork Wed Nov 29 20:43:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 842755 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="CdfusPrl"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="l09MbJ6m"; 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 3ynCH04Qzkz9s72 for ; Thu, 30 Nov 2017 07:45:48 +1100 (AEDT) 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=X9Qdgc+CSwlbQF6ddniI06CSgStF6bq9Bj3HHzXoFPg=; b=CdfusPrlVDF2LRVYO8+mqieyuQ F+3vUaeIsOWWWX+1JeU4Qxzb6QkWE2JfmqrcGGOOilKM+QNwN1Fr8M67Frwfqz7Fg4MvJM0Z/Gjv7 dVN0WRVBhSxUdHu1us9CdMJwxVgBsk6qLUbT2h/4PYsWiX+hvcrlldK4T8xTI2VjpQBxke+BFzYZA dSXeJ7Zb7tULfmGDU2x//wtKCiUijIXBch0hKVaaLidR+h9eEWRXM2/X5ZL//FVSN4ELKkYy/LGTw SLB1vQE/uY78r4k68s97Dva+oRJWCqyXpDhBxv3DWN10hCmYOOGppY4JixGAjCFE1G4FzYiC4GIFr 8FfpTlzA==; 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 1eK9Eh-0005BY-LQ; Wed, 29 Nov 2017 20:45:39 +0000 Received: from mail-it0-x243.google.com ([2607:f8b0:4001:c0b::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eK9Dk-0002vH-19 for linux-mtd@lists.infradead.org; Wed, 29 Nov 2017 20:44:47 +0000 Received: by mail-it0-x243.google.com with SMTP id u62so5652660ita.2 for ; Wed, 29 Nov 2017 12:44:19 -0800 (PST) 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=6lb9r2Tpng3MeYboqwqNi3q0hyK/1KeRugukBanQDpk=; b=l09MbJ6mVOwK3rT4AMmOZ/9cIIMv3evAVqRWbXq/lHGL1TGebI9a+NZqsRRevQldiH 95QuzklpiRniHdPUe+6AXtpMft/t9euKTl9RrNhfAqspcUywpAz19a6OgQEjvop0/129 MdTXmXVgSy+vGyppeiBezKsXA8rSbQShh7wVYnHdA4Krho/S9dqHwZ9AkR+l49XU3nt5 10tGlI2pcW5q2caqiUDYJBFv03gil2NQKxq0C5d4xoShzL0znd7Ecxp6oiGIY+cyePPZ 11lUUTHYn/Vit2nOnxIjlcN+QI8E55N/sCVCkybZ/SU6NFIOzEqx4kwTWhz0Dh8Q2aP4 b2gg== 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=6lb9r2Tpng3MeYboqwqNi3q0hyK/1KeRugukBanQDpk=; b=Mg848pDRpe1YZ1X4QmRxOqCtOqw/8M0qtxQHQFf9DLe6gN3AbmVh9sRihLc9Qp7YdL 4adnNo+zieMPH5eUDSFIloYF7VgebrC8QKlAmMWT0xE2RUepEov60TmvljwuhS8XtViS B2AKXzz+l9JoXWt1wQWi8+QiMtr8mx/MDfLSmqCHcIF+WbmXMyATMT6sSoMBOCw7ZCsq xF8aONxo2raGA3kq18tX6EzgE1Le20K8GZW7eO9V0XpJaW6vYHpj1recBeR/ZaDxRm1Z an/R4lkYykGmbNcuzmOiO7c5cqfIpaFc+EfAIehw0k2KSTDvTpMWEzE+VOPUGXrStjRv 6b9w== X-Gm-Message-State: AJaThX6GhCHDeyLE6jo9NpAxR21tsyPKemdVw0GdGIjLPaKDEd4bu86j aGPXUEPK7CNtjgCqZ9JC3RwsvmAGHKY= X-Google-Smtp-Source: AGs4zMbWmEgEiX/bllaJQ570ctrqiCBp0Ao0hStI6dFvV0GIRt6lco1P4d2rhPH9bFzpqEBxqbytQg== X-Received: by 10.36.20.68 with SMTP id 65mr94882itg.147.1511988258562; Wed, 29 Nov 2017 12:44:18 -0800 (PST) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.175.88]) by smtp.gmail.com with ESMTPSA id l4sm1111112ioc.69.2017.11.29.12.44.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Nov 2017 12:44:18 -0800 (PST) From: Eric Biggers To: linux-mtd@lists.infradead.org, Richard Weinberger Subject: [PATCH v2 3/5] ubifs: switch to fscrypt_prepare_rename() Date: Wed, 29 Nov 2017 12:43:15 -0800 Message-Id: <20171129204317.91205-4-ebiggers3@gmail.com> X-Mailer: git-send-email 2.15.0.531.g2ccb3012c9-goog In-Reply-To: <20171129204317.91205-1-ebiggers3@gmail.com> References: <20171129204317.91205-1-ebiggers3@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171129_124440_660380_7672524C X-CRM114-Status: GOOD ( 11.58 ) X-Spam-Score: -1.8 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:4001:c0b:0:0:0:243 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -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: linux-fscrypt@vger.kernel.org, Eric Biggers , Adrian Hunter , Artem Bityutskiy 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);