git: b5b16659c5ac - main - tmpfs: disallow truncation to set file size past RLIMIT_FSIZE
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 24 Sep 2022 16:42:36 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=b5b16659c5aceb9caa0a9b76c7746e1d12a505ce
commit b5b16659c5aceb9caa0a9b76c7746e1d12a505ce
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-09-18 13:28:11 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-09-24 16:41:30 +0000
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
---
sys/fs/tmpfs/tmpfs_subr.c | 4 ++++
1 file changed, 4 insertions(+)
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