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: 369337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7929C433E0 for ; Fri, 22 Jan 2021 21:35:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 728A423B08 for ; Fri, 22 Jan 2021 21:35:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729034AbhAVVe1 (ORCPT ); Fri, 22 Jan 2021 16:34:27 -0500 Received: from lilium.sigma-star.at ([109.75.188.150]:32920 "EHLO lilium.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729342AbhAVVcC (ORCPT ); Fri, 22 Jan 2021 16:32:02 -0500 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 Cc: david@sigma-star.at, richard@nod.at, linux-kernel@vger.kernel.org, stable@vger.kernel.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 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.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);