aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2022-09-18 13:28:11 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2022-10-08 00:29:35 +0000
commit064d5d4dee053f70ff82f9a1f98ed42e38f36b47 (patch)
tree3f657bff798c006be1b041cac3b7dfdfd087bde0
parent27ec1f0833a153c4052c74e0863c556057735b26 (diff)
downloadsrc-064d5d4dee053f70ff82f9a1f98ed42e38f36b47.tar.gz
src-064d5d4dee053f70ff82f9a1f98ed42e38f36b47.zip
tmpfs: disallow truncation to set file size past RLIMIT_FSIZE
PR: 164793 (cherry picked from commit b5b16659c5aceb9caa0a9b76c7746e1d12a505ce)
-rw-r--r--sys/fs/tmpfs/tmpfs_subr.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index 6c8d9bd9a0ff..f60dc81c648c 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -2045,6 +2045,10 @@ tmpfs_chsize(struct vnode *vp, u_quad_t size, struct ucred *cred,
if (node->tn_flags & (IMMUTABLE | APPEND))
return (EPERM);
+ error = vn_rlimit_trunc(size, td);
+ if (error != 0)
+ return (error);
+
error = tmpfs_truncate(vp, size);
/*
* tmpfs_truncate will raise the NOTE_EXTEND and NOTE_ATTRIB kevents