From nobody Mon Dec 13 23:35:49 2021 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 4867718E2493; Mon, 13 Dec 2021 23:35:50 +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 4JCdDQ089Dz4ZMb; Mon, 13 Dec 2021 23:35:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D8E881DA95; Mon, 13 Dec 2021 23:35:49 +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 1BDNZneL018793; Mon, 13 Dec 2021 23:35:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BDNZnSK018792; Mon, 13 Dec 2021 23:35:49 GMT (envelope-from git) Date: Mon, 13 Dec 2021 23:35:49 GMT Message-Id: <202112132335.1BDNZnSK018792@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: fe04c91184e9 - main - nfscl: add a filesize limit check to nfs_allocate() 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: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fe04c91184e9e82609a657c4e6e70e213ed3a859 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639438550; 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=bMXbNcVfjuPgmrElvVlooJndO5HpvQL5JJJtUdudSio=; b=JRa9hSWJe7ULL05nAFRm/uTcLVJg2tomV7ztnsicSukMdRrR3iPhBo1BI9TIXpvqAcG8xT IGqO3Z8uiUuAZya+J6pzK/eZB/rNrvCTr4Q8aplA+z+Y9/7CDVyBYlOeigiGYxO90Op5Pa x6OCrJG6fYLMw+ROdnbZ8a8jEC3uuGBT7vQLg1ucRXYuV94ah3dE0PTjeDlImTX0dGepDa ER9BFuNFTyBktWzzL/A9SGEkFfRhmLO+TavkldQwk+xycBUwHRcFK7TKfQTrTdZi6PabQr Iin6LsaM33XKaK6DumVLww/XGNvTbbiEVktBc9+qEOjzR2UbXS5qm44ZFCYV1Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639438550; a=rsa-sha256; cv=none; b=wyiIltjR+aXtJmdxa3ou0lbvM4+bsJIk+B7Sro4UtaWwIYA1QB0mcTurIt+2LNIqgOXUP/ MTXAXywYWPSOx+nXYM43dE6xcJVFfis/4AML2E1/s/YicrPvOpCbecH6uI310UUt+IXZiQ 6DWnZBdA1WcYnDhvli5nUeTuvVmmB0/c5faEINanvXEWUa+dyxYBNvELLqsfFj/Hsrws1C SMlWNkLmb5vOt1Mgy0oEJT7Fh7TJW/tSJMRXFXdhxg3HccXq//ljTQfS4cstZPq+C12jGC B40pvJGyakVTdEC7dTYC4k/n/AYVweTLjC3nfAXXaXjEhOg5/L9fyOPRYibM2Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=fe04c91184e9e82609a657c4e6e70e213ed3a859 commit fe04c91184e9e82609a657c4e6e70e213ed3a859 Author: Rick Macklem AuthorDate: 2021-12-13 23:32:19 +0000 Commit: Rick Macklem CommitDate: 2021-12-13 23:32:19 +0000 nfscl: add a filesize limit check to nfs_allocate() As reported in PR#260343, nfs_allocate() did not check the filesize rlimit. This patch adds that check. PR: 260343 Reviewed by: asomers MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D33422 --- sys/fs/nfsclient/nfs_clvnops.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 4a027ea07f26..ba2ba27b8fb6 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -3761,6 +3761,7 @@ nfs_allocate(struct vop_allocate_args *ap) off_t alen; int attrflag, error, ret; struct timespec ts; + struct uio io; attrflag = 0; nmp = VFSTONFS(vp->v_mount); @@ -3769,18 +3770,24 @@ nfs_allocate(struct vop_allocate_args *ap) if (NFSHASNFSV4(nmp) && nmp->nm_minorvers >= NFSV42_MINORVERSION && (nmp->nm_privflag & NFSMNTP_NOALLOCATE) == 0) { mtx_unlock(&nmp->nm_mtx); + alen = *ap->a_len; + if ((uint64_t)alen > nfs_maxalloclen) + alen = nfs_maxalloclen; + + /* Check the file size limit. */ + io.uio_offset = *ap->a_offset; + io.uio_resid = alen; + error = vn_rlimit_fsize(vp, &io, td); + /* * Flush first to ensure that the allocate adds to the * file's allocation on the server. */ - error = ncl_flush(vp, MNT_WAIT, td, 1, 0); - if (error == 0) { - alen = *ap->a_len; - if ((uint64_t)alen > nfs_maxalloclen) - alen = nfs_maxalloclen; + if (error == 0) + error = ncl_flush(vp, MNT_WAIT, td, 1, 0); + if (error == 0) error = nfsrpc_allocate(vp, *ap->a_offset, alen, &nfsva, &attrflag, ap->a_cred, td, NULL); - } if (error == 0) { *ap->a_offset += alen; *ap->a_len -= alen;