Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1355865pxb; Fri, 22 Jan 2021 13:39:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJydXOnGsm8IyprrXx2olHsLUOUTDMBb+jdw7iBzj7uRnHnNZMFirEBw1bACrVRkFrIE9vhH X-Received: by 2002:aa7:c485:: with SMTP id m5mr4699835edq.320.1611351581024; Fri, 22 Jan 2021 13:39:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611351581; cv=none; d=google.com; s=arc-20160816; b=DTPMUeCkTDC/dBONbKHZkQgvS9EBRIcyRpnfBTizng772xuyhCcwe1cyE6+ntCA/RS uMJRFZfJpPiGoJaIE/UHSyZODvdrM24uRJc01dt/LqFeNZttAQ3XrWzh5isaenVvl1Fe BgSsaDQGM8MTzRnbGxfw7YAAsThg7ljT9GjuhaNU+2qCVttMIqKSk5tyPrpz2lJtkule H9c6UAtodDPN2ijzrL3kqKhAOxoRCCtPD4vS1RPmX8tkohRqOq3UOgvGpAb08CiFoEXE T8YnkcTfsgHZpVxuNAqubl+XPT2a18w7fxVZXyt0w23PQbmjyy/fyLxeCvBk8bT4V7TG 5Nqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1m3amVoUy+ZsvZWKxVqFXlnaWD/WOcHWx34cyCVsrfQ=; b=jt1oVp4U+tDN5DdZgUeJO10B2rz3RmbekLoVqlWi7Jo7ATQwevagAlhawwqKnjA3mR EZUYSUrFfOJRMktvFdIRDlNKhi4fOAr7m8lxohqJjZzJmvmAG19US1h+3OCCV/bSTtIv rDlskOlCsvLTQDedntAr7a3cf+y5XHHL1vzjXGeEhdipPkb8/mnonc4uOvJ26OYBKDlE KBp3LtmRDXEjASqT6ioF+aW1GAv/A8InSkwptgd+mN2iMSRBUVluzwkoPkDibKUp+jn4 z1iqcZprUe3L0j966lu9O9+NJer7AOkfPsDg41X1zTFaRa18wpRtItLyDr84eU+FLAki RkPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qw12si3535710ejb.550.2021.01.22.13.39.16; Fri, 22 Jan 2021 13:39:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729138AbhAVVht (ORCPT + 99 others); Fri, 22 Jan 2021 16:37:49 -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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- 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, stru= ct inode *dir, struct inode *inode =3D d_inode(old_dentry); struct ubifs_inode *ui =3D ubifs_inode(inode); struct ubifs_inode *dir_ui =3D ubifs_inode(dir); - int err, sz_change =3D CALC_DENT_SIZE(dentry->d_name.len); + int err, sz_change; struct ubifs_budget_req req =3D { .new_dent =3D 1, .dirtied_ino =3D 2, .dirtied_ino_d =3D ALIGN(ui->data_len, 8) }; struct fscrypt_name nm; @@ -731,6 +731,8 @@ static int ubifs_link(struct dentry *old_dentry, stru= ct inode *dir, if (inode->i_nlink =3D=3D 0) ubifs_delete_orphan(c, inode->i_ino); =20 + sz_change =3D CALC_DENT_SIZE(fname_len(&nm)); + inc_nlink(inode); ihold(inode); inode->i_ctime =3D current_time(inode); --=20 2.26.2