aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2022-09-18 11:51:33 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2022-10-08 00:29:36 +0000
commit337b0852e942205246f16c30a923900edbb16a8c (patch)
tree4e4ff0f1b8bd08c225d7c6cb736f17dbe32e5207
parent55b41282d698bed4b3bb75b74265992c2cf5f42b (diff)
downloadsrc-337b0852e942205246f16c30a923900edbb16a8c.tar.gz
src-337b0852e942205246f16c30a923900edbb16a8c.zip
msdosfs: truncate write if it would exceed the fs max file size or RLIMIT_FSIZE
PR: 164793 (cherry picked from commit a9c439ba104d83a2666d114dae9f26b2efb22d17)
-rw-r--r--sys/fs/msdosfs/msdosfs_vnops.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
index b9f1b678e534..94af83b5a0a6 100644
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ b/sys/fs/msdosfs/msdosfs_vnops.c
@@ -618,7 +618,7 @@ msdosfs_write(struct vop_write_args *ap)
{
int n;
int croffset;
- ssize_t resid;
+ ssize_t resid, r;
u_long osize;
int error = 0;
u_long count;
@@ -663,16 +663,15 @@ msdosfs_write(struct vop_write_args *ap)
/*
* The caller is supposed to ensure that
* uio->uio_offset >= 0 and uio->uio_resid >= 0.
- */
- if ((uoff_t)uio->uio_offset + uio->uio_resid > MSDOSFS_FILESIZE_MAX)
- return (EFBIG);
-
- /*
+ *
* If they've exceeded their filesize limit, tell them about it.
*/
- error = vn_rlimit_fsize(vp, uio, uio->uio_td);
- if (error != 0)
+ error = vn_rlimit_fsizex(vp, uio, MSDOSFS_FILESIZE_MAX, &r,
+ uio->uio_td);
+ if (error != 0) {
+ vn_rlimit_fsizex_res(uio, r);
return (error);
+ }
/*
* If the offset we are starting the write at is beyond the end of
@@ -682,8 +681,10 @@ msdosfs_write(struct vop_write_args *ap)
*/
if (uio->uio_offset > dep->de_FileSize) {
error = deextend(dep, uio->uio_offset, cred);
- if (error)
+ if (error != 0) {
+ vn_rlimit_fsizex_res(uio, r);
return (error);
+ }
}
/*
@@ -826,6 +827,7 @@ errexit:
}
} else if (ioflag & IO_SYNC)
error = deupdat(dep, 1);
+ vn_rlimit_fsizex_res(uio, r);
return (error);
}