From nobody Thu Dec 29 20:56:25 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 4Njgff412xz2lFfR; Thu, 29 Dec 2022 20:56:26 +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 4Njgff1Gvdz3kmZ; Thu, 29 Dec 2022 20:56:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672347386; 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=igTH5emoxB9MqboMg+uEnvClKQfSI4fMnjvKw/m4OfY=; b=hMbQIhGENDvmTJKhFtk/dNb6OwyFHrqLjXvLmjUJxwWP89OmJBsyAyzbLBNUN6EjG77Q1C kp/fWqRg6h57wI038kp73Bat1jUNDz9mw30YPmbxitxvavKltRi4SfHroobxk2dxWWHmUn /TixiYawYdLaS/WwUN0IkgxMN0XZfoD6HHsko1RFRU8523+1TMKTAsL5eWi2LGzlRLU0hL A2yth05TntX2id0xQsObT2qTFgs4MAIviMUesSPqiVyEWZtDu0nyC/iTit2z2cYsLZMFt/ Cvc1qZ9YtbjMt6dpu30i9l7uMb25k027pf0I8Y9RTfJ2v6gtP9k9dr9p3sYM2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672347386; 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=igTH5emoxB9MqboMg+uEnvClKQfSI4fMnjvKw/m4OfY=; b=UnmS8d54tO/JIYQH9NSXgvKj0ysJJcDp/Z5g4kS+u+o1fXnfW9okMVoA//BrevSHHJ+h12 JW0iuW5Uhz83Nh4Rm6jPv58l/eUrx5dJ/ClUmMnvtNtMHrZvZF1ijmY6/TR1d5Y27aeJj6 q5k/pkzYmc5pDQ0Y6vhl0/uxi/3uVdaMLdcEj8GTfu3H8gpbNJ1CorbcpGXCgJEu9coAGZ TVCrs1xnlAjDdIEQnr7qot3mK9kUXZYgCxleROVz1slifjBX/RQ86Zxpwhu0nATTVAolgy ZersOhHaJOGdocY1CesRO2aLExUj+tq1wAakCXt6Ucjnpj3ME3r2TIe5I3bkBQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1672347386; a=rsa-sha256; cv=none; b=JU3LP6Yt+aC0NCazspxHlipQfpf9mKXe8EU05wypqW/mwU0N4BQw/cchwbZnMmPGfcSd24 qBwZzJEsNDAHow+SXiJCiut63lcbgPZ8V5NemV8nRDRd8sYOv/ei3AYdZDfup3iUhMjF3h 9zqoMeA9qyJAroABjzK11e6rnmVa7OWT0uVCzeuzHFobGgku8kotOc/HgaMYur5Rtg3w6s XRe+8vn4X8T/ZnSgrofm2y9R6udwdyXB3nhbfxRcYlmXku+Blqcs1BRlpxxARbIegRJ8sT TELU6jztR82o9SAEK1q9/fSf/3SpQsWTjf+wOEiErFTPEe9rKi/O7ML5Bvj0Qw== 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 4Njgff0NfKzj4Y; Thu, 29 Dec 2022 20:56:26 +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 2BTKuPr7047485; Thu, 29 Dec 2022 20:56:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BTKuPux047484; Thu, 29 Dec 2022 20:56:25 GMT (envelope-from git) Date: Thu, 29 Dec 2022 20:56:25 GMT Message-Id: <202212292056.2BTKuPux047484@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: 701b36961cbd - main - ufs/suspend: deny suspension if the calling process has a file from mp opened for write 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: 701b36961cbd2084c36eb828402d0ef89211d929 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=701b36961cbd2084c36eb828402d0ef89211d929 commit 701b36961cbd2084c36eb828402d0ef89211d929 Author: Konstantin Belousov AuthorDate: 2022-12-28 18:14:52 +0000 Commit: Konstantin Belousov CommitDate: 2022-12-29 20:55:39 +0000 ufs/suspend: deny suspension if the calling process has a file from mp opened for write Also deny suspension if we cannot check the above condition race-free because there is more than one thread in the calling process. PR: 267628, 267630 Reviewed by: mckusick Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37896 --- 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);