From nobody Sat Sep 24 16:42:40 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 4MZZZ91gv6z4d3N0; Sat, 24 Sep 2022 16:42:41 +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 4MZZZ90WmWz3GWk; Sat, 24 Sep 2022 16:42:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664037761; 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=yqic8OZ+jxgLAz+PRrQ7p4FpmV6Nju+lkBdeAwyhKxM=; b=wbtYekdg8bpUR5jajG559MWhxw33tO0AgZGik66PnZf8FZvFJCZNWkoOipktaKC/mV4mxK WfJXero8+nyvq5YmGUUtlpz9cNTwNBW+vFynZOUe9qALSqOnijmKnQRWCvKgaUmTH66LpE uHlLAcBZTr3hebjoMq+tde5hvlXR9/uTsc0LyOKqzIjIW7p2yf+zk3yx82wvIqF+rgw7yh T9WIncmehpNZSZPVOE3ilC24bAlBsW4P7ILe92bVOdterVnVIDQgIVc37muOKuli07pi9C uoguiG7HUSYwieMyePhztZ2Q3Lw5mdULzvEbFTHXy1li5E5qv68vUdlFhKETuA== 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 4MZZZ86JWGz17mC; Sat, 24 Sep 2022 16:42:40 +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 28OGgen0058220; Sat, 24 Sep 2022 16:42:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28OGgedh058219; Sat, 24 Sep 2022 16:42:40 GMT (envelope-from git) Date: Sat, 24 Sep 2022 16:42:40 GMT Message-Id: <202209241642.28OGgedh058219@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: 8bdb2695d697 - main - tmpfs: 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/main X-Git-Reftype: branch X-Git-Commit: 8bdb2695d69710b7f2e7cc20820aab8b3f4668a6 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664037761; 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=yqic8OZ+jxgLAz+PRrQ7p4FpmV6Nju+lkBdeAwyhKxM=; b=Y/SIQQULVLFTFDLEAoA+QW86q2VmTfwswAVmkAkLYVXshuB6Ov4Nea9+Wf9QJQOgdlS5xA ob3cVLqG1Tdx4MOH0HRZS8ZEF8pJX8InkRfEnQBzLknGnzFop3fx2FlXwYSSfXz4OTy68C mbfAPkAFcVG8wnSK1jVe0HRrKAXLO7Xy20UaZyiQv5Oo8OOi1vd7OznNn+NQBNmEW4F5z5 P4VnyhxSQDR9koBonPIcZiu3VeGLFTP6vf9kwLhCeh1nSt7AtzrBW2OVzh76/BH68qAXsW Rh11vaMRtnG6qcT0NoV3iIfUK21McTZodSE4/cEDJ1Gr94KHOUg43FStb3D+kA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664037761; a=rsa-sha256; cv=none; b=Xdhi0V4LCkU95jgbC+dDqrKCL7mu89TcKWTWj02x7sgUvAtiOP5LvkBZgB+cxiO94HjJMa 3CsC0f3PJCPvTpTS/1UsVXj9SYXfvOa+Pm1IfGL05PnOxCgbGULGIdLmoEbfFl+gyx4xI2 RzEH7pEl7amHl9d3jwIXBg8L1K3Vy3a5d5A72GOrQrWfFtE3fB3Dtmd32W98m73YX/Crqd AmUp+gASNNIHKpKfJvokuSkw8v729s6mfcDV/YiYI3DlgzuTQn0UTyAMmWNP6Nkh6oZS9Q iUAZPVetJzOjWPhSIHtIKm2alj0+AcS/AHUYGM/qjNO1+fBpbS6VS/tJgg0OFA== 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=8bdb2695d69710b7f2e7cc20820aab8b3f4668a6 commit 8bdb2695d69710b7f2e7cc20820aab8b3f4668a6 Author: Konstantin Belousov AuthorDate: 2022-09-18 13:27:28 +0000 Commit: Konstantin Belousov CommitDate: 2022-09-24 16:42:05 +0000 tmpfs: 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/tmpfs/tmpfs_vnops.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 079936946270..7a9ffed9696c 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -639,6 +639,7 @@ tmpfs_write(struct vop_write_args *v) struct uio *uio; struct tmpfs_node *node; off_t oldsize; + ssize_t r; int error, ioflag; mode_t newmode; @@ -655,12 +656,12 @@ tmpfs_write(struct vop_write_args *v) return (0); if (ioflag & IO_APPEND) uio->uio_offset = node->tn_size; - if (uio->uio_offset + uio->uio_resid > - VFS_TO_TMPFS(vp->v_mount)->tm_maxfilesize) - return (EFBIG); - error = vn_rlimit_fsize(vp, uio, uio->uio_td); - if (error != 0) + error = vn_rlimit_fsizex(vp, uio, VFS_TO_TMPFS(vp->v_mount)-> + tm_maxfilesize, &r, uio->uio_td); + if (error != 0) { + vn_rlimit_fsizex_res(uio, r); return (error); + } if (uio->uio_offset + uio->uio_resid > node->tn_size) { error = tmpfs_reg_resize(vp, uio->uio_offset + uio->uio_resid, @@ -687,6 +688,7 @@ out: MPASS(IMPLIES(error == 0, uio->uio_resid == 0)); MPASS(IMPLIES(error != 0, oldsize == node->tn_size)); + vn_rlimit_fsizex_res(uio, r); return (error); }