From patchwork Fri Jan 22 21:22:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 1430572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=0lXMkiA1; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DMshF6PVYz9sCD for ; Sat, 23 Jan 2021 08:23:57 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=IyGgkYnSN6yOV49FhHy8KdFme52IloXVhNJSXp+vvK4=; b=0lXMkiA1QAqkFzV2p6uvCfe56 RiVlso7BDNxeIB1uUH1OTl9Hdq+YtXpyaLHZA5g1zMafcr/Lpif+UsPEwDytqJ3X2/rE4P2o/KvfK WFk1cF5vq8rQKaWHgOy+QZg4NlySMuZ4fnFB4dERJfGhyImt7+veQ/W3JZvHydjem12e5gWCL7Xlx OFrTyB2TDHz8AcsaKxRXTffg3VjpUD07xGnPFp9SzHyyb8FtC/nsMcQUd/me3x7KQQAfzrJWjO9bl Yot/Hl5Ldt4tov6wPdbAx0YEKvS5vuix96M5rjP2VqEPh+Xoz0wVxgrLEdCGW8k3ysRGVuI5Oclvj ctbPFJK4w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l33tI-0002E3-8Q; Fri, 22 Jan 2021 21:22:48 +0000 Received: from lilium.sigma-star.at ([109.75.188.150]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l33t9-0002Br-J3 for linux-mtd@lists.infradead.org; Fri, 22 Jan 2021 21:22:42 +0000 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id 2D753181CBE03; Fri, 22 Jan 2021 22:22:35 +0100 (CET) Received: from lilium.sigma-star.at ([127.0.0.1]) by localhost (lilium.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id sQ4Lpq5mXoJP; Fri, 22 Jan 2021 22:22:34 +0100 (CET) Received: from lilium.sigma-star.at ([127.0.0.1]) by localhost (lilium.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id vxMwvqs7u1ha; Fri, 22 Jan 2021 22:22:34 +0100 (CET) From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [PATCH 1/4] ubifs: Correctly set inode size in ubifs_link() Date: Fri, 22 Jan 2021 22:22:26 +0100 Message-Id: <20210122212229.17072-2-richard@nod.at> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210122212229.17072-1-richard@nod.at> References: <20210122212229.17072-1-richard@nod.at> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210122_162240_103070_31C41F3C X-CRM114-Status: GOOD ( 10.43 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: richard@nod.at, david@sigma-star.at, linux-kernel@vger.kernel.org, stable@vger.kernel.org Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We need to use fscrypt filename handling wrappers when calculating the size of a directory entry, otherwise UBIFS will report the wrong value (size of plain instead of cihper text) for st_size of a directory if fscrypt is enabled. Cc: stable@vger.kernel.org Fixes: f4f61d2cc6d8 ("ubifs: Implement encrypted filenames") Signed-off-by: Richard Weinberger Reviewed-by: Zhihao Cheng --- fs/ubifs/dir.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 9a6b8660425a..04912dedca48 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -693,7 +693,7 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir, struct inode *inode = d_inode(old_dentry); struct ubifs_inode *ui = ubifs_inode(inode); struct ubifs_inode *dir_ui = ubifs_inode(dir); - int err, sz_change = CALC_DENT_SIZE(dentry->d_name.len); + int err, sz_change; struct ubifs_budget_req req = { .new_dent = 1, .dirtied_ino = 2, .dirtied_ino_d = ALIGN(ui->data_len, 8) }; struct fscrypt_name nm; @@ -731,6 +731,8 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir, if (inode->i_nlink == 0) ubifs_delete_orphan(c, inode->i_ino); + sz_change = CALC_DENT_SIZE(fname_len(&nm)); + inc_nlink(inode); ihold(inode); inode->i_ctime = current_time(inode);