lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <176246794705.2863550.4386662432074837729.stgit@frogsfrogsfrogs>
Date: Thu, 06 Nov 2025 14:40:07 -0800
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org
Subject: [PATCH 3/3] fuse2fs: adjust OOM killer score if possible

From: Darrick J. Wong <djwong@...nel.org>

Users don't like it when their filesystems go down unexpectedly.  Set
the OOM score adjustment to -500 to try to prevent this, particularly
because fuse2fs doesn't support journal transactions.

Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
 misc/fuse2fs.c |   27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)


diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 86e0222a51369a..d6be5e9968567c 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -242,6 +242,7 @@ struct fuse2fs {
 
 	int logfd;
 	int blocklog;
+	int oom_score_adj;
 	unsigned int blockmask;
 	unsigned long offset;
 	unsigned int next_generation;
@@ -5298,6 +5299,7 @@ static struct fuse_opt fuse2fs_opts[] = {
 	FUSE2FS_OPT("norecovery",	norecovery,		1),
 	FUSE2FS_OPT("noload",		norecovery,		1),
 	FUSE2FS_OPT("offset=%lu",	offset,			0),
+	FUSE2FS_OPT("oom_score_adj=%d",	oom_score_adj,		-500),
 	FUSE2FS_OPT("kernel",		kernel,			1),
 	FUSE2FS_OPT("directio",		directio,		1),
 	FUSE2FS_OPT("acl",		acl,			1),
@@ -5508,19 +5510,31 @@ static void try_set_io_flusher(struct fuse2fs *ff)
 #endif
 }
 
+/* Try to adjust the OOM score so that we don't get killed */
+static void try_adjust_oom_score(struct fuse2fs *ff)
+{
+	FILE *fp = fopen("/proc/self/oom_score_adj", "w+");
+
+	if (!fp)
+		return;
+
+	fprintf(fp, "%d\n", ff->oom_score_adj);
+	fclose(fp);
+}
+
 int main(int argc, char *argv[])
 {
 	struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
-	struct fuse2fs fctx;
+	struct fuse2fs fctx = {
+		.magic = FUSE2FS_MAGIC,
+		.logfd = -1,
+		.bfl = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER,
+		.oom_score_adj = -500,
+	};
 	errcode_t err;
 	FILE *orig_stderr = stderr;
 	int ret;
 
-	memset(&fctx, 0, sizeof(fctx));
-	fctx.magic = FUSE2FS_MAGIC;
-	fctx.logfd = -1;
-	fctx.bfl = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
-
 	ret = fuse_opt_parse(&args, &fctx, fuse2fs_opts, fuse2fs_opt_proc);
 	if (ret)
 		exit(1);
@@ -5554,6 +5568,7 @@ int main(int argc, char *argv[])
 	}
 
 	try_set_io_flusher(&fctx);
+	try_adjust_oom_score(&fctx);
 
 	/* Will we allow users to allocate every last block? */
 	if (getenv("FUSE2FS_ALLOC_ALL_BLOCKS")) {


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ