From nobody Sat Oct 08 00:39:12 2022 X-Original-To: dev-commits-src-all@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 4MkmX06cmvz4fGH0; Sat, 8 Oct 2022 00:39:12 +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 4MkmX068kDz3pcS; Sat, 8 Oct 2022 00:39:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665189552; 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=25gkUj5GgPz62p24o28HgBnBhzQO75iGUZX49wTZTwk=; b=N3A6zYrxisz5cW9hE7jG7SgP7woC1wpIsmo7B9vjoZ08ITaupbBFYh2YxHsH1za6zxMw5m vOB2yQ2gt4wK6M3qXFr65AbA3xDHhfroS/x7weBLgs2r/h8bXNroQ3TkXe8vCwZXt0/5JP 2BTLi4chO0OC39OyGGbcwxHTbcHrrFCUJYRNf2FqoN+iC3WmvPf+1ZM/vS2u3qDqhRgctH +GfV2v1CYm9krJfdPHIhirOeG6VKdIZMca1xGWlDyZlynP67U9CPyWlhguqobqBIvUBaUs etKYVdG86WhqaXGTkAafTlw77A+IFCc6LMxxKFBG6/BVWpAZDIqeoTNZt5uw/w== 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 4MkmX05CT6zmVR; Sat, 8 Oct 2022 00:39:12 +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 2980dCjX034431; Sat, 8 Oct 2022 00:39:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2980dC9u034430; Sat, 8 Oct 2022 00:39:12 GMT (envelope-from git) Date: Sat, 8 Oct 2022 00:39:12 GMT Message-Id: <202210080039.2980dC9u034430@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 337b0852e942 - stable/13 - msdosfs: truncate write if it would exceed the fs max file size or RLIMIT_FSIZE List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 337b0852e942205246f16c30a923900edbb16a8c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665189552; 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=25gkUj5GgPz62p24o28HgBnBhzQO75iGUZX49wTZTwk=; b=Tn6/cKKd1bcdaqYdc94KuozfWKd2y7iwlrYrj3yExXzxK5jZcOIvsf7pbn0vxf6KI3f4/G MmXJVsHDhBsyIuT5jkyc86ds9we5GVZC6z6bFXP2MnK91EqjtDgTRQ8LoIYwYjhDg0tOxE CfH5g+1nqN4pM/x15s9+Ray1bcV3ttAhmUSSB3/m55XO6jcALQZfam/qLanNei0xYGeufx bOfQulpsqMKS52f+YvbliESMSYQWOtVbWvQ7S4frmG2dQhJ0eepYaiPrynWkC8SI4m8dNq 3Gwjui19qMmEYFtZAPhUhfAG4vKUBRqmWwIhuBIPFQ76uSU2ffqQ5Aexm6FEwA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665189552; a=rsa-sha256; cv=none; b=nnZzriexvW78hDOm7QeXeEuG59imTom4VWJ3QfpNoucQWHqUjwAcDQe/BmDGXV0ZzfekbV 5KCQgAQ6M35ke7Yv12TKPCJOvLn38GAVDcXlJMUovRv4x2sVUreqhAlYMOnE5RyucOjNo1 NJIXs4Ln3JeGLebQMA+uUXaJoR/UTFp8hTa+jrYDMo52lXBqr0/B+0kxFeTeHWytfA6oaQ 5kskA3j00cQPjHhA7yUiBkMsh/gyfSjR4QGK+Nn4UyKGKy/09pAU9FHBHI/hqyCJPB0QRy SZaCM/KyIakNkWtWg+FwNrDcYkTcYCkme0PZx3kIGap86Bkwcmsu+LFWnB4HFQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=337b0852e942205246f16c30a923900edbb16a8c commit 337b0852e942205246f16c30a923900edbb16a8c Author: Konstantin Belousov AuthorDate: 2022-09-18 11:51:33 +0000 Commit: Konstantin Belousov CommitDate: 2022-10-08 00:29:36 +0000 msdosfs: truncate write if it would exceed the fs max file size or RLIMIT_FSIZE PR: 164793 (cherry picked from commit a9c439ba104d83a2666d114dae9f26b2efb22d17) --- 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 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); }