[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH v2 4/4] kernel: Beim Prozessende Interrupthandler austragen



! kernel: Interrupts an geloeschte Prozessen zu schicken ist keine
  besonders gute Idee
! kernel: Buffer Overflow beim Registrieren eines Nicht-IRQ-Interrupts
  fuer Userspaceprozesse gefixt

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/kernel/include/intr.h |    1 +
 src/kernel/src/intr.c     |   17 ++++++++++++++++-
 src/kernel/src/task.c     |    3 +++
 3 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/src/kernel/include/intr.h b/src/kernel/include/intr.h
index f07bf61..a9e558b 100644
--- a/src/kernel/include/intr.h
+++ b/src/kernel/include/intr.h
@@ -17,6 +17,7 @@
 void init_idt(void);
 void set_intr(int intr, word selector, void* handler, int dpl, int type);
 void set_intr_handling_task(byte intr, struct task * task);
+void remove_intr_handling_task(struct task* task);
 
 typedef void(*pfIrqHandler)(int, dword*);
 
diff --git a/src/kernel/src/intr.c b/src/kernel/src/intr.c
index 42f64fb..a317235 100644
--- a/src/kernel/src/intr.c
+++ b/src/kernel/src/intr.c
@@ -428,12 +428,27 @@ void set_intr_handling_task(byte intr, struct task * task)
             (i == MAX_INTERRUPTS - 1))
         {
             intr_handling_task[intr][i] = task;
-            irqs_to_send[intr - IRQ_BASE][i] = 0;
+            if (intr >= IRQ_BASE && intr < IRQ_BASE + 16) {
+                irqs_to_send[intr - IRQ_BASE][i] = 0;
+            }
             break;
         }
     }
 }
 
+void remove_intr_handling_task(struct task* task)
+{
+    int i, intr;
+
+    for (intr = 0; intr < 256; intr++) {
+        for (i = 0; i < MAX_INTERRUPTS; i++) {
+            if (intr_handling_task[intr][i] == task) {
+                intr_handling_task[intr][i] = NULL;
+            }
+        }
+    }
+}
+
 void handle_exception(dword* esp)
 {
     struct int_stack_frame * isf = *((struct int_stack_frame **)esp);
diff --git a/src/kernel/src/task.c b/src/kernel/src/task.c
index 1a5b47a..59c05df 100644
--- a/src/kernel/src/task.c
+++ b/src/kernel/src/task.c
@@ -285,6 +285,9 @@ void destroy_task(struct task* task_ptr)
             next_task->parent_task = get_task(1);
         }
     }
+
+    // Interrupthandler ausschalten
+    remove_intr_handling_task(task_ptr);
     
     
     // Melde das Beenden des Tasks per RPC an init
-- 
1.6.0.2