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

[tyndur-devel] [PATCH] kernel: RPC zu unbekanntem Prozess tolerieren



* kernel: Wenn jemand zu einem unbekannten Prozess einen RPC machen
  will, sollte man ihm das einfach sagen statt ihn abzuschiessen.
---
 src/kernel/src/syscall.c       |    6 ++--
 src/modules/include/syscall.h  |    3 +-
 src/modules/lib/syscalls/rpc.c |   41 +++++++++++++++++++++++++++++++++++----
 3 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/src/kernel/src/syscall.c b/src/kernel/src/syscall.c
index 2ee793d..87911fa 100644
--- a/src/kernel/src/syscall.c
+++ b/src/kernel/src/syscall.c
@@ -34,6 +34,7 @@
  */  
 
 #include <stdint.h>
+#include <errno.h>
 
 #include "console.h"
 #include "syscall.h"
@@ -668,8 +669,7 @@ void syscall(struct int_stack_frame ** esp)
             struct task* callee = get_task(callee_pid);
 
             if (!callee) {
-                abort_task("SYSCALL_FASTRPC: RPC zu unbekanntem Prozess %d)",
-                    callee_pid);
+                isf->eax = -ESRCH;
                 break;
             }
 
@@ -693,7 +693,7 @@ void syscall(struct int_stack_frame ** esp)
             )) {
                 schedule_to_task(callee, (dword*) esp);
             } else {
-                isf->eax = -1;
+                isf->eax = -EAGAIN;
                 schedule((dword*)esp);
             }
             break;
diff --git a/src/modules/include/syscall.h b/src/modules/include/syscall.h
index e22b0df..6bb3593 100644
--- a/src/modules/include/syscall.h
+++ b/src/modules/include/syscall.h
@@ -72,7 +72,8 @@ void set_rpc_handler(void (*rpc_handler)(void));
 void add_intr_handler(dword intr);
 
 void rpc(pid_t pid);
-void send_message(pid_t pid, dword function, dword correlation_id, dword len, char* data);
+int send_message(pid_t pid, dword function, dword correlation_id,
+    dword len, char* data);
 void wait_for_rpc(void);
 void v_and_wait_for_rpc(void);
 
diff --git a/src/modules/lib/syscalls/rpc.c b/src/modules/lib/syscalls/rpc.c
index 72d4bbc..2a07352 100644
--- a/src/modules/lib/syscalls/rpc.c
+++ b/src/modules/lib/syscalls/rpc.c
@@ -1,5 +1,34 @@
-#include "types.h"
-#include "syscall.h"
+/*
+ * Copyright (c) 2006-2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Kevin Wolf.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <types.h>
+#include <syscall.h>
+#include <errno.h>
 
 void rpc(dword pid) 
 {
@@ -16,10 +45,10 @@ void rpc(dword pid)
     } while (result != 0);
 }
 
-void send_message
+int send_message
     (dword pid, dword function, dword correlation_id, dword len, char* data)
 {
-    dword result = 0;
+    int32_t result = 0;
 
     // Auf die Variable wird zwar sonst nirgends schreibend zugegriffen, aber
     // das volatile ist noetig, weil gcc sonst der Meinung ist, der Arrayinhalt
@@ -42,6 +71,8 @@ void send_message
         : "i" (SYSCALL_FASTRPC), "g" (pid), "i" (0x8), "g" (metadata), 
             "g" (len), "g" (data), "0" (result));
 
-    } while (result != 0);
+    } while (result == -EAGAIN);
+
+    return result;
 }
 
-- 
1.6.0.2