summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuís Henriques <ocfs2-devel@oss.oracle.com>2023-05-29 16:26:45 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-06-21 15:38:58 +0200
commitfa8dfc7aa7bd9d4e227a97615b535292713d9db5 (patch)
treef79cb0ca7a764eb6976ff22968447c9051adfea6
parent2b88ccb9333723353d9f6c15f85088ac7f8ac57c (diff)
downloadlinux-stable-fa8dfc7aa7bd9d4e227a97615b535292713d9db5.tar.gz
linux-stable-fa8dfc7aa7bd9d4e227a97615b535292713d9db5.tar.bz2
linux-stable-fa8dfc7aa7bd9d4e227a97615b535292713d9db5.zip
ocfs2: check new file size on fallocate call
commit 26a6ffff7de5dd369cdb12e38ba11db682f1dec0 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/ocfs2/file.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index e671fbdd4b86..60b7098f7a11 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2109,14 +2109,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;