git: 00c0e20c5180 - stable/13 - ufs/suspend: deny suspension if the calling process has a file from mp opened for write
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 20 Jan 2023 03:23:51 UTC
The branch stable/13 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=00c0e20c5180284298910dcf0a677243b2c28f7d
commit 00c0e20c5180284298910dcf0a677243b2c28f7d
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-12-28 18:14:52 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
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 <sys/systm.h>
#include <sys/buf.h>
#include <sys/conf.h>
+#include <sys/filedesc.h>
#include <sys/ioccom.h>
#include <sys/jail.h>
#include <sys/mount.h>
@@ -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);