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
This commit is contained in:
Konstantin Belousov 2022-09-18 14:49:57 +03:00
parent 2ac083f60f
commit 70385088ca

View File

@ -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)