From deedb462a09890f7cfb63880203be962ca4a0fd9 Mon Sep 17 00:00:00 2001
From: vvb2060 <vvb2060@gmail.com>
Date: Wed, 25 Oct 2023 00:00:33 +0800
Subject: [PATCH] Hide magisk internal mount point

---
 native/src/core/daemon.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/native/src/core/daemon.cpp b/native/src/core/daemon.cpp
index 7122db803..3472a1b64 100644
--- a/native/src/core/daemon.cpp
+++ b/native/src/core/daemon.cpp
@@ -392,6 +392,13 @@ static void daemon_entry() {
     ssprintf(path, sizeof(path), "%s/" ROOTOVL, tmp);
     rm_rf(path);
 
+    // Unshare magiskd
+    xunshare(CLONE_NEWNS);
+    // Hide magisk internal mount point
+    xmount(nullptr, tmp, nullptr, MS_PRIVATE | MS_REC, nullptr);
+    // Fix sdcardfs bug on old kernel
+    xmount(nullptr, "/mnt", nullptr, MS_SLAVE | MS_REC, nullptr);
+
     // Use isolated devpts if kernel support
     if (access("/dev/pts/ptmx", F_OK) == 0) {
         ssprintf(path, sizeof(path), "%s/" SHELLPTS, tmp);