aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2022-09-18 11:49:57 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2022-09-24 16:41:22 +0000
commit70385088cafaab3365c5243f22b8fc9c712c1fde (patch)
tree3f62b41502bdbb382f16256ec3f251899b93acc1
parent2ac083f60f8c9ce361c3daf691c60486459d87ae (diff)
downloadsrc-70385088cafaab3365c5243f22b8fc9c712c1fde.tar.gz
src-70385088cafaab3365c5243f22b8fc9c712c1fde.zip
UFS: disallow truncation to set file size past RLIMIT_FSIZE
This is mandated by POSIX. 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/ufs/ufs/ufs_vnops.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index cf101ae50750..9ea38bc149a5 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -755,6 +755,9 @@ ufs_setattr(
*/
return (0);
}
+ error = vn_rlimit_trunc(vap->va_size, td);
+ if (error != 0)
+ return (error);
if ((error = UFS_TRUNCATE(vp, vap->va_size, IO_NORMAL |
((vap->va_vaflags & VA_SYNC) != 0 ? IO_SYNC : 0),
cred)) != 0)