linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
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	[thread overview]
Message-ID: <20210122212229.17072-2-richard@nod.at> (raw)
In-Reply-To: <20210122212229.17072-1-richard@nod.at>

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 <richard@nod.at>
---
 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);
-- 
2.26.2


  reply	other threads:[~2021-01-22 21:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22 21:22 [PATCH 0/4] Assorted UBIFS fixes Richard Weinberger
2021-01-22 21:22 ` Richard Weinberger [this message]
2021-01-23  2:35   ` [PATCH 1/4] ubifs: Correctly set inode size in ubifs_link() Zhihao Cheng
2021-01-22 21:22 ` [PATCH 2/4] ubifs: Don't add fscrypt context to xattrs Richard Weinberger
2021-01-22 21:22 ` [PATCH 3/4] ubifs: Update directory size when creating whiteouts Richard Weinberger
2021-01-23  2:45   ` Zhihao Cheng
2021-01-23 10:05     ` Richard Weinberger
2021-01-25  1:05     ` Zhihao Cheng
2021-01-25  7:55       ` Richard Weinberger
2021-01-25  9:31         ` Zhihao Cheng
2021-01-22 21:22 ` [PATCH 4/4] ubifs: Harden ubifs_jnl_write_inode() Richard Weinberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210122212229.17072-2-richard@nod.at \
    --to=richard@nod.at \
    --cc=david@sigma-star.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).