mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ocfs2: check new file size on fallocate call
@ 2023-05-29 15:26 Luís Henriques
  2023-05-31  3:32 ` Mark Fasheh
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Luís Henriques @ 2023-05-29 15:26 UTC (permalink / raw)
  To: Mark Fasheh, Joel Becker, Joseph Qi, Heming Zhao
  Cc: ocfs2-devel, linux-kernel, Luís Henriques

When changing a file size with fallocate() the new size isn't being
checked.  In particular, the FSIZE ulimit isn't being checked, which makes
fstest generic/228 fail.  Simply adding a call to inode_newsize_ok() fixes
this issue.

Signed-off-by: Luís Henriques <lhenriques@suse.de>
---
 fs/ocfs2/file.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index efb09de4343d..b173c36bcab3 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2100,14 +2100,20 @@ static long ocfs2_fallocate(struct file *file, int mode, loff_t offset,
 	struct ocfs2_space_resv sr;
 	int change_size = 1;
 	int cmd = OCFS2_IOC_RESVSP64;
+	int ret = 0;
 
 	if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
 		return -EOPNOTSUPP;
 	if (!ocfs2_writes_unwritten_extents(osb))
 		return -EOPNOTSUPP;
 
-	if (mode & FALLOC_FL_KEEP_SIZE)
+	if (mode & FALLOC_FL_KEEP_SIZE) {
 		change_size = 0;
+	} else {
+		ret = inode_newsize_ok(inode, offset + len);
+		if (ret)
+			return ret;
+	}
 
 	if (mode & FALLOC_FL_PUNCH_HOLE)
 		cmd = OCFS2_IOC_UNRESVSP64;

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-06-01  1:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-29 15:26 [PATCH] ocfs2: check new file size on fallocate call Luís Henriques
2023-05-31  3:32 ` Mark Fasheh
2023-05-31  6:00 ` Joseph Qi
2023-05-31  8:29   ` Luís Henriques
2023-05-31  8:31     ` Joseph Qi
2023-05-31  8:32 ` Joseph Qi
2023-05-31 22:11 ` [Ocfs2-devel] " Andrew Morton
2023-06-01  1:23   ` Joseph Qi

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®