git: 701b73858e3a - main - msdosfs: disallow truncation to set file size past RLIMIT_FSIZE

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sat, 24 Sep 2022 16:42:35 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=701b73858e3afa15d8ca2ea4aa480173ccc5960e

commit 701b73858e3afa15d8ca2ea4aa480173ccc5960e
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-09-18 11:51:03 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-09-24 16:41:26 +0000

    msdosfs: 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/msdosfs/msdosfs_vnops.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
index 8573db682698..24d63bd343a9 100644
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ b/sys/fs/msdosfs/msdosfs_vnops.c
@@ -456,6 +456,9 @@ msdosfs_setattr(struct vop_setattr_args *ap)
 			 */
 			break;
 		}
+		error = vn_rlimit_trunc(vap->va_size, td);
+		if (error != 0)
+			return (error);
 		error = detrunc(dep, vap->va_size, 0, cred);
 		if (error)
 			return error;