git: 3936744da50c - stable/13 - UFS: disallow truncation to set file size past RLIMIT_FSIZE

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sat, 08 Oct 2022 00:39:06 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=3936744da50c0f10466780305208f61542131898

commit 3936744da50c0f10466780305208f61542131898
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-09-18 11:49:57 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-10-08 00:29:35 +0000

    UFS: disallow truncation to set file size past RLIMIT_FSIZE
    
    PR:     164793
    
    (cherry picked from commit 70385088cafaab3365c5243f22b8fc9c712c1fde)
---
 sys/ufs/ufs/ufs_vnops.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index c4af984745bf..71cee6ad7181 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -754,6 +754,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)