From nobody Sat Oct 08 00:39:05 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 4MkmWt1V1zz4fGLy; Sat, 8 Oct 2022 00:39:06 +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 4MkmWs74MPz3p1F; Sat, 8 Oct 2022 00:39:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665189546; 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=4YoCWIRa5qZqXj7kS0jMihqhRuxmKNKe/9ofEXSC0ME=; b=w9rJuxbHAs0z6iItwZCg3bBq5FCj1F5w9s2E/r4lc7lxCgihfX02G6D5yv334EsYYAqdEX WEkjw64YZMr2o6onoMpcMIubKeAguyrB+Ik2nRbdPZ915uJE74XDo1bysviuNHqye6dDbz bOLcNYBRJIeptFTkReN1+bfA2RfYUpJdjdR//MQvhGO2Kc51IJWOOLqoD/EXM4+WKQ/fWg opJZnlXWK1uQEurWv4YbLFVHipSLSMDjjbiB2f/lAgA2woEs22KKt0WmXGUPfzr4HyyEsu NB561ofQVYGzvnxHJXFDl0nP1oqvVmcCC483GivecFFLpMSebsnR6o/azpxrmQ== 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 4MkmWs69m5zmYK; Sat, 8 Oct 2022 00:39:05 +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 2980d5bC034274; Sat, 8 Oct 2022 00:39:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2980d5Ss034273; Sat, 8 Oct 2022 00:39:05 GMT (envelope-from git) Date: Sat, 8 Oct 2022 00:39:05 GMT Message-Id: <202210080039.2980d5Ss034273@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: 9ec3a87c969d - stable/13 - Add vn_rlimit_trunc() 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: 9ec3a87c969da7de438ef5aa67cdc7f43d0dc894 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665189546; 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=4YoCWIRa5qZqXj7kS0jMihqhRuxmKNKe/9ofEXSC0ME=; b=Lf+gvg7Kl5P2l+jiFbOqQUAE7N8aamUxv02zeMHqUMiAvhn4b3yVzLdMZTlmipiTINQ4V/ pTCcaGHJe71WlsYvIBi7BljbWI9bPDiKYBG8Y9al19gb5sXlZnP7usbIw+J3no5pR4qFI0 hrfAc0UPKyup/z8K6UjS43QUow/9kDALq5qAdWqdDpYSvsSCnMsJKe2xnE/J/Yku9+I3Se zPYqhJYDmPAXECsXBNkRDT4nfG17Hd6kMoIcv8dBUgLUPb7/BtGAiPkylLg4tvTwi8vpt+ H5UWdKoBblaZLMrVapT5ImP/uy3vP6rkw9hGsfezmuzk95KrTToUwxwyLKCEAQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665189546; a=rsa-sha256; cv=none; b=mz9OL2jK4DBCl5uB3bytQFRTRNUVXavWxxvFGF3ZqwlFcdtkrij8E0/x3eTDvgfDUHpr6M MovHTX6dedCH7VbQCI/XD9b9QRnIBJu2/UheLYe2zB5P2XUURL0ZV3avas5fdEtL5qMFXP HlGsh7W0ctWjw8qvkyKM5ErgsiUD+ZVtBXDKT5bMqnK+1zH398g2ykWAzaznuplhWjsJXM Af3XCUH8FV1Ql7eQezstx8vhioPhoOCwouZ2gu1so+z2FQOapaOVI+TwycGL9+CCmr9ShM lXHiqO6tvSzum1cy7k3GxLIOlddqXWcbVDaBzbU0dTVuuvF/1ygwmHn3RDlhRw== 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=9ec3a87c969da7de438ef5aa67cdc7f43d0dc894 commit 9ec3a87c969da7de438ef5aa67cdc7f43d0dc894 Author: Konstantin Belousov AuthorDate: 2022-09-18 19:52:13 +0000 Commit: Konstantin Belousov CommitDate: 2022-10-08 00:29:35 +0000 Add vn_rlimit_trunc() (cherry picked from commit 2ac083f60f8c9ce361c3daf691c60486459d87ae) --- sys/kern/vfs_vnops.c | 24 +++++++++++++++++++----- sys/sys/vnode.h | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 3089aca3468f..a7043ae818f5 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2361,6 +2361,23 @@ vn_vget_ino_gen(struct vnode *vp, vn_get_ino_t alloc, void *alloc_arg, return (error); } +static void +vn_send_sigxfsz(struct proc *p) +{ + PROC_LOCK(p); + kern_psignal(p, SIGXFSZ); + PROC_UNLOCK(p); +} + +int +vn_rlimit_trunc(u_quad_t size, struct thread *td) +{ + if (size <= lim_cur(td, RLIMIT_FSIZE)) + return (0); + vn_send_sigxfsz(td->td_proc); + return (EFBIG); +} + int vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, struct thread *td) @@ -2389,11 +2406,8 @@ vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, (td->td_pflags2 & TDP2_ACCT) != 0) return (0); - if (!ktr_write || ktr_filesize_limit_signal) { - PROC_LOCK(td->td_proc); - kern_psignal(td->td_proc, SIGXFSZ); - PROC_UNLOCK(td->td_proc); - } + if (!ktr_write || ktr_filesize_limit_signal) + vn_send_sigxfsz(td->td_proc); return (EFBIG); } diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 6d3e7eac8b23..599b42b98239 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -779,6 +779,7 @@ int vn_rdwr_inchunks(enum uio_rw rw, struct vnode *vp, void *base, int vn_read_from_obj(struct vnode *vp, struct uio *uio); int vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, struct thread *td); +int vn_rlimit_trunc(u_quad_t size, struct thread *td); int vn_start_write(struct vnode *vp, struct mount **mpp, int flags); int vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags);