blob: a36fd494b5666ae68c02a2af0c855d7e8392c0fa [file]
From d05008fdf683e82262fc510c73d8f471e8b20805 Mon Sep 17 00:00:00 2001
From: Shengken Lin <shengken.lin@amlogic.corp-partner.google.com>
Date: Tue, 3 Jun 2025 11:29:39 +0800
Subject: [PATCH] FS: overlayfs: Add a parameter to disable overlayfs
Bug: 422002934
Test: cat /sys/module/kernel/parameters/nooverlayfs
Change-Id: I5b8ed76af3c938aa08ba6a49dd6411b1808365eb
Signed-off-by: Shengken Lin <shengken.lin@amlogic.corp-partner.google.com>
---
fs/overlayfs/super.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index a550f356cbd8..26f367596ca0 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -11,6 +11,7 @@
#include <linux/mount.h>
#include <linux/parser.h>
#include <linux/module.h>
+#include <linux/moduleparam.h>
#include <linux/statfs.h>
#include <linux/seq_file.h>
#include <linux/posix_acl_xattr.h>
@@ -26,6 +27,7 @@ MODULE_DESCRIPTION("Overlay filesystem");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY);
+static bool nooverlayfs; /* Disable overlayfs */
struct ovl_dir_cache;
@@ -1533,6 +1535,11 @@ static int __init ovl_init(void)
{
int err;
+ if (nooverlayfs) {
+ pr_info("overlayfs is disabled\n");
+ return 0;
+ }
+
ovl_inode_cachep = kmem_cache_create("ovl_inode",
sizeof(struct ovl_inode), 0,
(SLAB_RECLAIM_ACCOUNT|
@@ -1556,6 +1563,9 @@ static int __init ovl_init(void)
static void __exit ovl_exit(void)
{
+ if (nooverlayfs)
+ return;
+
unregister_filesystem(&ovl_fs_type);
/*
@@ -1567,5 +1577,11 @@ static void __exit ovl_exit(void)
ovl_aio_request_cache_destroy();
}
+#ifdef MODULE
+module_param(nooverlayfs, bool, 0444);
+#else
+core_param(nooverlayfs, nooverlayfs, bool, 0444);
+#endif
+
module_init(ovl_init);
module_exit(ovl_exit);
--
2.34.1