mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: <richard@nod.at>, <s.hauer@pengutronix.de>, <miquel.raynal@bootlin.com>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	<chengzhihao1@huawei.com>, <yukuai3@huawei.com>
Subject: [PATCH 1/6] ubifs: Rectify space budget for ubifs_symlink() if symlink is encrypted
Date: Tue, 11 Oct 2022 11:47:27 +0800	[thread overview]
Message-ID: <20221011034732.45605-2-chengzhihao1@huawei.com> (raw)
In-Reply-To: <20221011034732.45605-1-chengzhihao1@huawei.com>

Fix bad space budget when symlink file is encrypted. Bad space budget
may let make_reservation() return with -ENOSPC, which could turn ubifs
to read-only mode in do_writepage() process.

Fetch a reproducer in [Link].

Link: https://bugzilla.kernel.org/show_bug.cgi?id=216490
Fixes: ca7f85be8d6cf9 ("ubifs: Add support for encrypted symlinks")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
 fs/ubifs/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index bc11276301fd..4705d9a77357 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1150,7 +1150,6 @@ static int ubifs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
 	int err, sz_change, len = strlen(symname);
 	struct fscrypt_str disk_link;
 	struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
-					.new_ino_d = ALIGN(len, 8),
 					.dirtied_ino = 1 };
 	struct fscrypt_name nm;
 
@@ -1166,6 +1165,7 @@ static int ubifs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
 	 * Budget request settings: new inode, new direntry and changing parent
 	 * directory inode.
 	 */
+	req.new_ino_d = ALIGN(disk_link.len - 1, 8);
 	err = ubifs_budget_space(c, &req);
 	if (err)
 		return err;
-- 
2.31.1


  reply	other threads:[~2022-10-11  3:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11  3:47 [PATCH 0/6] ubifs: Fix wrong space calculation while doing budget Zhihao Cheng
2022-10-11  3:47 ` Zhihao Cheng [this message]
2022-10-11  3:47 ` [PATCH 2/6] ubifs: Rectify space budget for ubifs_xrename() Zhihao Cheng
2022-10-11  3:47 ` [PATCH 3/6] ubifs: Add comments and debug info " Zhihao Cheng
2022-10-11  3:47 ` [PATCH 4/6] ubifs: Fix wrong dirty space budget for dirty inode Zhihao Cheng
2022-10-11  3:47 ` [PATCH 5/6] ubifs: do_rename: Fix wrong space budget when target inode's nlink > 1 Zhihao Cheng
2022-10-11  3:47 ` [PATCH 6/6] ubifs: Reserve one leb for each journal head while doing budget Zhihao Cheng
2022-11-18  8:53 ` [PATCH 0/6] ubifs: Fix wrong space calculation " Zhihao Cheng
2022-11-18  8:56   ` Richard Weinberger
2022-11-18  8:58     ` Zhihao Cheng

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=20221011034732.45605-2-chengzhihao1@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=s.hauer@pengutronix.de \
    --cc=yukuai3@huawei.com \
    /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

all inboxes | Powered by JetHome®