[Bug 164793] [kern] RLIMIT_FSIZE does not work, affecting ftruncate(2) and truncate(2)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 24 Sep 2022 16:43:16 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=164793 --- Comment #11 from commit-hook@FreeBSD.org --- A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=1b4b75171ee3f2213b7671878a910fd5ddb3306e commit 1b4b75171ee3f2213b7671878a910fd5ddb3306e Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-09-18 11:46:19 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-09-24 16:41:33 +0000 Add vn_rlimit_fsizex() and vn_rlimit_fsizex_res() The vn_rlimit_fsizex() function: - checks that the write does not exceed RLIMIT_FSIZE limit and fs maximum supported file size - truncates write length if it exceeds the RLIMIT_FSIZE or max file size, but there are some bytes to write - sends SIGXFSZ if RLIMIT_FSIZE would be exceed otherwise POSIX mandates the truncated write in case when some bytes can be written but whole write request fails the RLIMIT_FSIZE check. The function is supposed to be used from VOP_WRITE()s. Due to pecularity in the VFS generic write syscall layer, uio_resid must correctly reflect the written amount (noted by markj). Provide the dual vn_rlimit_fsizex_res() function to correct uio_resid after the clamp done in vn_rlimit_fsizex() on VOP_WRITE() return. 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/kern/vfs_vnops.c | 92 +++++++++++++++++++++++++++++++++++++++++++++------- sys/sys/vnode.h | 3 ++ 2 files changed, 83 insertions(+), 12 deletions(-) -- You are receiving this mail because: You are the assignee for the bug.