Skip to content

Commit 26a6fff

Browse files
Luís Henriquesakpm00
authored andcommitted
ocfs2: check new file size on fallocate call
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. Link: https://lkml.kernel.org/r/20230529152645.32680-1-lhenriques@suse.de Signed-off-by: Luís Henriques <lhenriques@suse.de> Reviewed-by: Mark Fasheh <mark@fasheh.com> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Gang He <ghe@suse.com> Cc: Jun Piao <piaojun@huawei.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 0e4d4ef commit 26a6fff

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fs/ocfs2/file.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2100,14 +2100,20 @@ static long ocfs2_fallocate(struct file *file, int mode, loff_t offset,
21002100
struct ocfs2_space_resv sr;
21012101
int change_size = 1;
21022102
int cmd = OCFS2_IOC_RESVSP64;
2103+
int ret = 0;
21032104

21042105
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
21052106
return -EOPNOTSUPP;
21062107
if (!ocfs2_writes_unwritten_extents(osb))
21072108
return -EOPNOTSUPP;
21082109

2109-
if (mode & FALLOC_FL_KEEP_SIZE)
2110+
if (mode & FALLOC_FL_KEEP_SIZE) {
21102111
change_size = 0;
2112+
} else {
2113+
ret = inode_newsize_ok(inode, offset + len);
2114+
if (ret)
2115+
return ret;
2116+
}
21112117

21122118
if (mode & FALLOC_FL_PUNCH_HOLE)
21132119
cmd = OCFS2_IOC_UNRESVSP64;

0 commit comments

Comments
 (0)