aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2022-09-18 13:28:11 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2022-09-24 16:41:30 +0000
commitb5b16659c5aceb9caa0a9b76c7746e1d12a505ce (patch)
tree7c7574eff4b48e9a9ec3dddffa29be743399c424
parent701b73858e3afa15d8ca2ea4aa480173ccc5960e (diff)
downloadsrc-b5b16659c5aceb9caa0a9b76c7746e1d12a505ce.tar.gz
src-b5b16659c5aceb9caa0a9b76c7746e1d12a505ce.zip
tmpfs: disallow truncation to set file size past RLIMIT_FSIZE
PR: 164793 Reviewed by: asomers, jah, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D36625
-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 be1eef1c3d89..7d589b1c193d 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -2120,6 +2120,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