Commit 44583d38 authored by Jeff Dike's avatar Jeff Dike

Merge uml.karaya.com:/home/jdike/linux/2.5/skas-2.5

into uml.karaya.com:/home/jdike/linux/2.5/skas-2.5-linus
parents 645dbacc 8bf1412a
......@@ -11,6 +11,8 @@
#include "helper.h"
#include "mconsole.h"
#include "os.h"
#include "choose-mode.h"
#include "mode.h"
struct dog_data {
int stdin;
......@@ -63,7 +65,8 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
args = mconsole_args;
}
else {
sprintf(pid_buf, "%d", tracing_pid);
/* XXX The os_getpid() is not SMP correct */
sprintf(pid_buf, "%d", CHOOSE_MODE(tracing_pid, os_getpid()));
args = pid_args;
}
......
......@@ -32,8 +32,8 @@ struct port_list {
struct port_dev {
struct port_list *port;
int fd;
int helper_pid;
int telnetd_pid;
int helper_pid;
int telnetd_pid;
};
struct connection {
......@@ -50,7 +50,7 @@ static void pipe_interrupt(int irq, void *data, struct pt_regs *regs)
struct connection *conn = data;
int fd;
fd = os_rcv_fd(conn->socket[0], &conn->helper_pid);
fd = os_rcv_fd(conn->socket[0], &conn->helper_pid);
if(fd < 0){
if(fd == -EAGAIN)
return;
......@@ -99,7 +99,8 @@ static int port_accept(struct port_list *port)
}
list_add(&conn->list, &port->pending);
return(1);
ret = 1;
goto out;
out_free:
kfree(conn);
......@@ -274,8 +275,6 @@ void port_kern_free(void *d)
{
struct port_dev *dev = d;
if(dev->helper_pid != -1) os_kill_process(dev->helper_pid, 0);
if(dev->telnetd_pid != -1) os_kill_process(dev->telnetd_pid, 0);
kfree(dev);
}
......
......@@ -120,16 +120,6 @@ static int signal_tramp(void *arg)
return((*proc)(NULL));
}
static void last_ditch_exit(int sig)
{
kmalloc_ok = 0;
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGHUP, SIG_DFL);
uml_cleanup();
exit(1);
}
static void sleeping_process_signal(int pid, int sig)
{
switch(sig){
......@@ -214,9 +204,6 @@ int tracer(int (*init_proc)(void *), void *sp)
signal(SIGSEGV, (sighandler_t) tracer_segv);
signal(SIGUSR1, signal_usr1);
set_handler(SIGINT, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
set_handler(SIGTERM, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
set_handler(SIGHUP, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
if(debug_trace){
printf("Tracing thread pausing to be attached\n");
stop();
......
......@@ -110,12 +110,14 @@ unsigned long start_vm;
unsigned long end_vm;
int ncpus = 1;
#ifdef CONFIG_MODE_TT
/* Pointer set in linux_main, the array itself is private to each thread,
* and changed at address space creation time so this poses no concurrency
* problems.
*/
static char *argv1_begin = NULL;
static char *argv1_end = NULL;
#endif
/* Set in early boot */
static int have_root __initdata = 0;
......@@ -123,6 +125,7 @@ long physmem_size = 32 * 1024 * 1024;
void set_cmdline(char *cmd)
{
#ifdef CONFIG_MODE_TT
char *umid, *ptr;
if(CHOOSE_MODE(honeypot, 0)) return;
......@@ -139,6 +142,7 @@ void set_cmdline(char *cmd)
snprintf(ptr, (argv1_end - ptr) * sizeof(*ptr), " [%s]", cmd);
memset(argv1_begin + strlen(argv1_begin), '\0',
argv1_end - argv1_begin - strlen(argv1_begin));
#endif
}
static char *usage_string =
......@@ -199,23 +203,28 @@ static int __init mode_tt_setup(char *line, int *add)
return(0);
}
__uml_setup("mode=tt", mode_tt_setup,
"mode=tt\n"
" When both CONFIG_MODE_TT and CONFIG_MODE_SKAS are enabled, this option\n"
" forces UML to run in tt (tracing thread) mode. It is not the default\n"
" because it's slower and less secure than skas mode.\n\n"
);
#else
#ifdef CONFIG_MODE_SKAS
#define DEFAULT_TT 0
static int __init mode_tt_setup(char *line, int *add)
{
printk("CONFIG_MODE_TT disabled - 'mode=tt' ignored\n");
return(0);
}
#else
#ifdef CONFIG_MODE_TT
#define DEFAULT_TT 1
static int __init mode_tt_setup(char *line, int *add)
{
printk("CONFIG_MODE_SKAS disabled - 'mode=tt' redundant\n");
return(0);
}
#else
#error Either CONFIG_MODE_TT or CONFIG_MODE_SKAS must be enabled
......@@ -224,6 +233,13 @@ __uml_setup("mode=tt", mode_tt_setup,
#endif
#endif
__uml_setup("mode=tt", mode_tt_setup,
"mode=tt\n"
" When both CONFIG_MODE_TT and CONFIG_MODE_SKAS are enabled, this option\n"
" forces UML to run in tt (tracing thread) mode. It is not the default\n"
" because it's slower and less secure than skas mode.\n\n"
);
int mode_tt = DEFAULT_TT;
static int __init Usage(char *line, int *add)
......@@ -307,8 +323,10 @@ int linux_main(int argc, char **argv)
setup_machinename(system_utsname.machine);
#ifdef CONFIG_MODE_TT
argv1_begin = argv[1];
argv1_end = &argv[1][strlen(argv[1])];
#endif
set_usable_vm(uml_physmem, get_kmem_end());
......
......@@ -15,10 +15,12 @@
#include "user_util.h"
#include "kern_util.h"
#include "mem_user.h"
#include "signal_user.h"
#include "user.h"
#include "init.h"
#include "mode.h"
#include "choose-mode.h"
#include "uml-config.h"
/* Set in set_stklim, which is called from main and __wrap_malloc.
* __wrap_malloc only calls it if main hasn't started.
......@@ -32,11 +34,6 @@ char *linux_prog;
#define STACKSIZE (8 * 1024 * 1024)
#define THREAD_NAME_LEN (256)
/* Never changed */
static char padding[THREAD_NAME_LEN] = {
[ 0 ... THREAD_NAME_LEN - 2] = ' ', '\0'
};
static void set_stklim(void)
{
struct rlimit lim;
......@@ -66,26 +63,43 @@ static __init void do_uml_initcalls(void)
}
}
static void last_ditch_exit(int sig)
{
CHOOSE_MODE(kmalloc_ok = 0, (void) 0);
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGHUP, SIG_DFL);
uml_cleanup();
exit(1);
}
extern int uml_exitcode;
int main(int argc, char **argv, char **envp)
{
char **new_argv;
sigset_t mask;
int ret, i;
char **new_argv;
/* Enable all signals - in some environments, we can enter with
* some signals blocked
/* Enable all signals except SIGIO - in some environments, we can
* enter with some signals blocked
*/
sigemptyset(&mask);
sigaddset(&mask, SIGIO);
if(sigprocmask(SIG_SETMASK, &mask, NULL) < 0){
perror("sigprocmask");
exit(1);
}
#ifdef CONFIG_MODE_TT
/* Allocate memory for thread command lines */
if(argc < 2 || strlen(argv[1]) < THREAD_NAME_LEN - 1){
char padding[THREAD_NAME_LEN] = {
[ 0 ... THREAD_NAME_LEN - 2] = ' ', '\0'
};
new_argv = malloc((argc + 2) * sizeof(char*));
if(!new_argv) {
perror("Allocating extended argv");
......@@ -103,6 +117,7 @@ int main(int argc, char **argv, char **envp)
perror("execing with extended args");
exit(1);
}
#endif
linux_prog = argv[0];
......@@ -120,6 +135,10 @@ int main(int argc, char **argv, char **envp)
}
new_argv[argc] = NULL;
set_handler(SIGINT, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
set_handler(SIGTERM, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
set_handler(SIGHUP, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
do_uml_initcalls();
ret = linux_main(argc, argv);
......@@ -141,8 +160,10 @@ extern void *__real_malloc(int);
void *__wrap_malloc(int size)
{
if(CAN_KMALLOC()) return(um_kmalloc(size));
else return(__real_malloc(size));
if(CAN_KMALLOC())
return(um_kmalloc(size));
else
return(__real_malloc(size));
}
void *__wrap_calloc(int n, int size)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment