From nobody Fri Jan 20 03:23:51 2023 X-Original-To: dev-commits-src-branches@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 4NylG05tcJz30vrh; Fri, 20 Jan 2023 03:23:52 +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 4NylG01c30z3p0V; Fri, 20 Jan 2023 03:23:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674185032; 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=xdscgEqS8kDE4Q4ILmdrpOgMm3Yz5ZqDlPTkcisvJsk=; b=uyPI+mfNHvGmUAHXCpS3KYSzilptR6Hb5j2ljHWD8RHidsevSMYBFZOC7MWLb4RWEy322s HXWsO/P4Z5ajIgVWvqzvMDfG851dcf+rOTZIroAE2OhVkcuHHp+3jolNiMIDWWvs+X7lBv voQxxjxC/YzG0XwgwZ3Cy0/5XLOm53XCwtoDpOeJ4+Okj8EcGk1iCBAHEMD4WuovfSeX3H XqgFhf8DPHJwFUmRp0nm6DEkc0z/YrRBbd36PJbK3iBlxFkLbg6/1b/Yf8fQ/0hziq9p+a wn1hMsGUIwUUrISgZiszFPqm0tDPnny2ChRXC6frEOyqtahwhU2t9B0srzwsFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674185032; 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=xdscgEqS8kDE4Q4ILmdrpOgMm3Yz5ZqDlPTkcisvJsk=; b=Lhm7YYUXyqc/mcN9OXZml95PEYyqZ40msslfUscuGd0sjsueiyWyEAjMzgwai1d25NP9KO X6lU5yH+BfsafEMapm+d3MJeVxAnJBcniPkcaMpndLJz9xNhr1coTt/Yc6GvAq6aaQ4x6g kzDr/rZLceW5S8ICl9acCe9IrMgd/ZCkSHGyKoMNeH6p3yzqVTPiE2WULDcb+lOk2iC2hf FC/lbSqghFzSof6BW5fjJtpJ8DukTelk07G51jjfCOV7FdRXifeURb4BEE1rvfmtbfvRiV tvNawg8QNvNGUgFVyGnCH2NB3r2u+anGlcQm/XAZyAPoBJprEpLSLo+rpjn1JQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674185032; a=rsa-sha256; cv=none; b=GXqqQC8lRpgsTpRLyt8X7iVvsMWZb9VkrcLwcqTC2iDkaDF+fT6yMP/qxZuKclY/9LvdN4 eAq0FsfbyUEv6ln0XMoSeiBxxitQo1eYg6uHuHbjgCxyiRH1PbD5QyHxBWkTdemOne+l6v VrFPQYeVkUANt437/tzRHpsUxpbiZIVy+v8tJHUIe0yY/BGwlhzewPHKfAxdl7eOxt3k4w EKAehOV+DByVxeyPfPHFcK30Y0XE2y6yGMmg4VfmODCIhGlieF1az24VLEOlKOFc+sNABP Gmybra73y8GLFgOdHoJrRlYEA35prIordQxCoL8ekGKhPiG5RRIqyDc6emuIvg== 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 4NylG00SL5zFyt; Fri, 20 Jan 2023 03:23:52 +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 30K3NpCr042740; Fri, 20 Jan 2023 03:23:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30K3Npe1042739; Fri, 20 Jan 2023 03:23:51 GMT (envelope-from git) Date: Fri, 20 Jan 2023 03:23:51 GMT Message-Id: <202301200323.30K3Npe1042739@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: 00c0e20c5180 - stable/13 - ufs/suspend: deny suspension if the calling process has a file from mp opened for write List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: 00c0e20c5180284298910dcf0a677243b2c28f7d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=00c0e20c5180284298910dcf0a677243b2c28f7d commit 00c0e20c5180284298910dcf0a677243b2c28f7d Author: Konstantin Belousov AuthorDate: 2022-12-28 18:14:52 +0000 Commit: Konstantin Belousov CommitDate: 2023-01-20 03:21:35 +0000 ufs/suspend: deny suspension if the calling process has a file from mp opened for write PR: 267628, 267630 Tested by: pho (cherry picked from commit 701b36961cbd2084c36eb828402d0ef89211d929) --- sys/ufs/ffs/ffs_suspend.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sys/ufs/ffs/ffs_suspend.c b/sys/ufs/ffs/ffs_suspend.c index e7c976b6e921..a68f25d5eed2 100644 --- a/sys/ufs/ffs/ffs_suspend.c +++ b/sys/ufs/ffs/ffs_suspend.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -302,6 +303,16 @@ ffs_susp_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, vfs_rel(mp); if (error != 0) break; + + /* + * Require single-thread curproc so that the check is not racey. + * XXXKIB: might consider to singlethread curproc instead. + */ + error = curproc->p_numthreads > 1 ? EDEADLK : + descrip_check_write_mp(curproc->p_fd, mp); + if (error != 0) + break; + error = ffs_susp_suspend(mp); if (error != 0) { vfs_unbusy(mp);