From nobody Sat Sep 24 16:42:39 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MZZZ80zP7z4d3BS; Sat, 24 Sep 2022 16:42:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MZZZ76X4Rz3GcQ; Sat, 24 Sep 2022 16:42:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664037759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=R55RTRZHErhpAO3FQwmRg0rUCAHKRyTXrtrF1OnsgeA=; b=hxlWlEScQvqhfQa4RCxYE0JS5TbOZu/qGUZB7lfTLoRMEYUSiLoX8Y+aJpibbIFxvgLR9r cDPZmmHn/LVbcf6n5Oj7B7E0hRUd4GpAj2QzBudB24G7qMzMyRxmfvUm4yzecJQpI5648x pqSO12nI0V34QB/Sf3ZoRAwySpsqwrywf2Xpeto+WjBTcW4qi+eRf5Bv2/Q1HxabsNv1Z/ ed9JnUEDMj5urIzUc4BOZOoU5AlxVJJU2CDyCAxMvezUUL5chkjZoP3hS1iQ0Vr8c4GPP9 SzlEc4p4oXZu7vbRN2QGnV3/H0BqehVTGgErXekP5R9kUDUyjeJd5MrxYGcGVg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MZZZ75XTbz17sL; Sat, 24 Sep 2022 16:42:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28OGgdNl058191; Sat, 24 Sep 2022 16:42:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28OGgdbq058190; Sat, 24 Sep 2022 16:42:39 GMT (envelope-from git) Date: Sat, 24 Sep 2022 16:42:39 GMT Message-Id: <202209241642.28OGgdbq058190@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: a9c439ba104d - main - msdosfs: truncate write if it would exceed the fs max file size or RLIMIT_FSIZE List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a9c439ba104d83a2666d114dae9f26b2efb22d17 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664037759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=R55RTRZHErhpAO3FQwmRg0rUCAHKRyTXrtrF1OnsgeA=; b=CkHQVy+TLud0rbnY9FE7mD2F2r1RbFgFzh1SlIUu4hlGZwu1Mpx75IoyArzfnyxH/YvB8E BdAMa56eCLw6VzdU3cZBMhiRE7eNK6XjRvcbdxmrsT8dBuN4RAieduRo5+3nlimsZbXguD edqGbohbQLKWqYIRpA+VwEg0RjjJvALQn+imBTt4ewWrDWlzzkvpgemuq7WGhQnNYXbEgj Mb/XP0wnxgQ+545ZreTT5Y4jGktOruenEi8ZI42pU/DOCa7GcMnxLOwQsvLf5PodYRPGTL k48uCrRMamTzqzminRXWQ80M3YkplY9HzmSmWYyUmeawof8BN/OckT40725Rpw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664037759; a=rsa-sha256; cv=none; b=YNNeDT3BJcIcb7wjWZw57hNQ5fZLw82erpVk+fsPDRtpNWx9fV9UCX/RCagPTfzwPeZbSK +pGmu18uSho1GOOBG1NlphFeiwuN1gs06QaD7VmtcpYmnsdbtxJmeFo6LtBmhvPwZPBgZ5 LfVE0EUXqbhJhiAldLSkBF8e88IfjBpd0XNwTJUhpbWlJcZbICSsG4o1qWX5scYu1B2ZRj SUXs62mqs7BWGxAK/eF0+aOs7gfGLhW7hlECUMtVx57QrPn+oYmbuMWaPzX3cz2ICUqbfg hHKDnZPmmysio6b/0eIjSoxuMhqtdSII7aLUNDR9SuEvE1UngnS9oTvCLaGdeQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a9c439ba104d83a2666d114dae9f26b2efb22d17 commit a9c439ba104d83a2666d114dae9f26b2efb22d17 Author: Konstantin Belousov AuthorDate: 2022-09-18 11:51:33 +0000 Commit: Konstantin Belousov CommitDate: 2022-09-24 16:42:01 +0000 msdosfs: truncate write if it would exceed the fs max file size or 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 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index 24d63bd343a9..8fb58a58b138 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -614,7 +614,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; @@ -659,16 +659,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 @@ -678,8 +677,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); + } } /* @@ -822,6 +823,7 @@ errexit: } } else if (ioflag & IO_SYNC) error = deupdat(dep, 1); + vn_rlimit_fsizex_res(uio, r); return (error); }