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 2/6] ubifs: Rectify space budget for ubifs_xrename()
Date: Tue, 11 Oct 2022 11:47:28 +0800 [thread overview]
Message-ID: <20221011034732.45605-3-chengzhihao1@huawei.com> (raw)
In-Reply-To: <20221011034732.45605-1-chengzhihao1@huawei.com>
There is no space budget for ubifs_xrename(). It may let
make_reservation() return with -ENOSPC, which could turn
ubifs to read-only mode in do_writepage() process.
Fix it by adding space budget for ubifs_xrename().
Fetch a reproducer in [Link].
Link: https://bugzilla.kernel.org/show_bug.cgi?id=216569
Fixes: 9ec64962afb170 ("ubifs: Implement RENAME_EXCHANGE")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
fs/ubifs/dir.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 4705d9a77357..eeda471f05ee 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1575,6 +1575,10 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
return err;
}
+ err = ubifs_budget_space(c, &req);
+ if (err)
+ goto out;
+
lock_4_inodes(old_dir, new_dir, NULL, NULL);
time = current_time(old_dir);
@@ -1600,6 +1604,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
unlock_4_inodes(old_dir, new_dir, NULL, NULL);
ubifs_release_budget(c, &req);
+out:
fscrypt_free_filename(&fst_nm);
fscrypt_free_filename(&snd_nm);
return err;
--
2.31.1
next prev parent 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 ` [PATCH 1/6] ubifs: Rectify space budget for ubifs_symlink() if symlink is encrypted Zhihao Cheng
2022-10-11 3:47 ` Zhihao Cheng [this message]
2022-10-11 3:47 ` [PATCH 3/6] ubifs: Add comments and debug info for ubifs_xrename() 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-3-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®