From nobody Sat Sep 24 16:42:32 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 4MZZZ122K8z4d3KS; Sat, 24 Sep 2022 16:42:33 +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 4MZZZ11L7kz3GNv; Sat, 24 Sep 2022 16:42:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664037753; 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=ViPjkE7MwFMUi1rPA9dBoMXqRRtC8nCcjjzBwc3rrmI=; b=S/hevQKPjrzTiz8fTezNYV3hbstEjlOlYkLp3J3bPNVf2kboT+mPQpcDA+c/ZGenZCV/fg 7MX3yA+OmenC8gI02qWZcjQv8Frxu+a5t6rFvqIlCsSiYYV25I93gqASnHeu9MUGoSxy8p DBR2RrVfSaDF9siHIxc7zTZbI0x07D/C5xwNonlakLd28bIoJb5VvZ3ttzgBY7coAV9woq 4DgTvXTdUw1j7DX+nIoOXXV2AaMVxOOoZi0RrbUaif7zv7TUln6m7VHxtQHOJAbCwFpefD I5lu/1BORF7bEJsSJuXUTeL8nyoRtv/VixRiYqyQh5pR20RL/zD+38xxfwPXyQ== 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 4MZZZ073vcz17sH; Sat, 24 Sep 2022 16:42:32 +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 28OGgWHr058030; Sat, 24 Sep 2022 16:42:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28OGgWOs058029; Sat, 24 Sep 2022 16:42:32 GMT (envelope-from git) Date: Sat, 24 Sep 2022 16:42:32 GMT Message-Id: <202209241642.28OGgWOs058029@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: 2ac083f60f8c - main - Add vn_rlimit_trunc() 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: 2ac083f60f8c9ce361c3daf691c60486459d87ae Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664037753; 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=ViPjkE7MwFMUi1rPA9dBoMXqRRtC8nCcjjzBwc3rrmI=; b=OW/hVN2VCnYD7aglzxU7HVOyc4lMHUDvXl765j2wnH+LAdvoAr7HpJk0U1xoJQuDAjHmPZ H/Md1/SA0x14bTZWi9ybOP7JXYJWgCMpIG25MNR7Xxt2aP4GZlzH7YTpLC6p+ILMYh/Id/ M4XiGoIj557bVfy1ROkDozgG2WdW++m9xKWwy/IqgB4TP1mwXTQHWy4ViWimddagk4Adlp jPEg4U0U+KIDoB/DcbDJdUFfjx8to71DaFxqsOA1eVG8DAZLjocGz/alOFscqrbd45M28B +HVZBAYsW6SrHBd/v9naPxgt2iJFCpDblBs3P4qoKqLwnRxfsJ226ldiNX6JYQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664037753; a=rsa-sha256; cv=none; b=Inw80Sm3ucvmtsUFmaRom3hYgULENd6rmOjx2wsVBWtCHbu7+jUZa/H0nxD/svYYpt+67F mEaKlP8aNYJ4ZXEeLsCifTPGlE7DzOoJuGBB9YCKhFJFpASOBHWm9LrbVTMTrBeZilQWqn uI6bq9m9fyAy3Fipt2xWYqQ4J2eFqu10J2uboUuNcWFnlN3iiEYCfLqAuwYgBYt5funkJs ol9XB5fPR2oWHI9U2x0/CFmbaezbTCtgNhHOAmkqNIwdDS/kte7LLoifHTHUiilQGzNe5N lGl0XsUTIjC1n+6dUw0rho+aYoStCAgu7E6Nl4/y3WD/I9UZ72jNVeihFsAzsQ== 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=2ac083f60f8c9ce361c3daf691c60486459d87ae commit 2ac083f60f8c9ce361c3daf691c60486459d87ae Author: Konstantin Belousov AuthorDate: 2022-09-18 19:52:13 +0000 Commit: Konstantin Belousov CommitDate: 2022-09-24 16:41:18 +0000 Add vn_rlimit_trunc() 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/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 1d2c4f332473..6eef39a37f25 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2372,6 +2372,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) @@ -2400,11 +2417,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 f3170d77e6d4..da17170cbb2d 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -786,6 +786,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);