Revert "Implement workqueue for unmounting"
This commit is contained in:
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"files.associations": {
|
|
||||||
"selinux.h": "c"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,6 @@
|
|||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <linux/uidgid.h>
|
#include <linux/uidgid.h>
|
||||||
#include <linux/version.h>
|
#include <linux/version.h>
|
||||||
#include <linux/workqueue.h>
|
|
||||||
#include <linux/binfmts.h>
|
#include <linux/binfmts.h>
|
||||||
#include <linux/tty.h>
|
#include <linux/tty.h>
|
||||||
|
|
||||||
@@ -63,13 +62,6 @@ static void ksu_try_escalate_for_uid(uid_t uid)
|
|||||||
remove_pending_root(uid);
|
remove_pending_root(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct workqueue_struct *ksu_workqueue;
|
|
||||||
|
|
||||||
struct ksu_umount_work {
|
|
||||||
struct work_struct work;
|
|
||||||
struct mnt_namespace *mnt_ns;
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool ksu_kernel_umount_enabled = true;
|
static bool ksu_kernel_umount_enabled = true;
|
||||||
|
|
||||||
static int kernel_umount_feature_get(u64 *value)
|
static int kernel_umount_feature_get(u64 *value)
|
||||||
@@ -516,29 +508,6 @@ static void try_umount(const char *mnt, bool check_mnt, int flags)
|
|||||||
ksu_umount_mnt(&path, flags);
|
ksu_umount_mnt(&path, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_umount_work(struct work_struct *work)
|
|
||||||
{
|
|
||||||
struct ksu_umount_work *umount_work = container_of(work, struct ksu_umount_work, work);
|
|
||||||
struct mnt_namespace *old_mnt_ns = current->nsproxy->mnt_ns;
|
|
||||||
|
|
||||||
current->nsproxy->mnt_ns = umount_work->mnt_ns;
|
|
||||||
|
|
||||||
try_umount("/odm", true, 0);
|
|
||||||
try_umount("/system", true, 0);
|
|
||||||
try_umount("/vendor", true, 0);
|
|
||||||
try_umount("/product", true, 0);
|
|
||||||
try_umount("/system_ext", true, 0);
|
|
||||||
try_umount("/data/adb/modules", false, MNT_DETACH);
|
|
||||||
|
|
||||||
// try umount ksu temp path
|
|
||||||
try_umount("/debug_ramdisk", false, MNT_DETACH);
|
|
||||||
|
|
||||||
// fixme: dec refcount
|
|
||||||
current->nsproxy->mnt_ns = old_mnt_ns;
|
|
||||||
|
|
||||||
kfree(umount_work);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ksu_handle_setuid(struct cred *new, const struct cred *old)
|
int ksu_handle_setuid(struct cred *new, const struct cred *old)
|
||||||
{
|
{
|
||||||
if (!new || !old) {
|
if (!new || !old) {
|
||||||
@@ -620,22 +589,17 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
|
|||||||
|
|
||||||
// fixme: use `collect_mounts` and `iterate_mount` to iterate all mountpoint and
|
// fixme: use `collect_mounts` and `iterate_mount` to iterate all mountpoint and
|
||||||
// filter the mountpoint whose target is `/data/adb`
|
// filter the mountpoint whose target is `/data/adb`
|
||||||
struct ksu_umount_work *umount_work = kmalloc(sizeof(struct ksu_umount_work), GFP_ATOMIC);
|
try_umount("/odm", true, 0);
|
||||||
if (!umount_work) {
|
try_umount("/system", true, 0);
|
||||||
pr_err("Failed to allocate umount_work\n");
|
try_umount("/vendor", true, 0);
|
||||||
return 0;
|
try_umount("/product", true, 0);
|
||||||
}
|
try_umount("/system_ext", true, 0);
|
||||||
|
|
||||||
// fixme: inc refcount
|
try_umount("/data/adb/modules", false, MNT_DETACH);
|
||||||
umount_work->mnt_ns = current->nsproxy->mnt_ns;
|
try_umount("/data/adb/kpm", false, MNT_DETACH);
|
||||||
|
|
||||||
INIT_WORK(&umount_work->work, do_umount_work);
|
// try umount ksu temp path
|
||||||
|
try_umount("/debug_ramdisk", false, MNT_DETACH);
|
||||||
queue_work(ksu_workqueue, &umount_work->work);
|
|
||||||
|
|
||||||
get_task_struct(current); // delay fix
|
|
||||||
ksu_set_current_proc_umounted();
|
|
||||||
put_task_struct(current);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -858,14 +822,6 @@ __maybe_unused int ksu_kprobe_exit(void)
|
|||||||
|
|
||||||
void __init ksu_core_init(void)
|
void __init ksu_core_init(void)
|
||||||
{
|
{
|
||||||
if (ksu_register_feature_handler(&kernel_umount_handler)) {
|
|
||||||
pr_err("Failed to register kernel_umount feature handler\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
ksu_workqueue = alloc_workqueue("ksu_umount", WQ_UNBOUND, 0);
|
|
||||||
if (!ksu_workqueue) {
|
|
||||||
pr_err("Failed to create ksu workqueue\n");
|
|
||||||
}
|
|
||||||
#ifdef CONFIG_KPROBES
|
#ifdef CONFIG_KPROBES
|
||||||
int rc = ksu_kprobe_init();
|
int rc = ksu_kprobe_init();
|
||||||
if (rc) {
|
if (rc) {
|
||||||
@@ -885,8 +841,4 @@ void ksu_core_exit(void)
|
|||||||
pr_info("ksu_core_exit\n");
|
pr_info("ksu_core_exit\n");
|
||||||
ksu_kprobe_exit();
|
ksu_kprobe_exit();
|
||||||
#endif
|
#endif
|
||||||
if (ksu_workqueue) {
|
|
||||||
flush_workqueue(ksu_workqueue);
|
|
||||||
destroy_workqueue(ksu_workqueue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user