Esempio n. 1
0
asmlinkage unsigned long
ia64_brk (unsigned long brk)
{
	unsigned long retval = sys_brk(brk);
	force_successful_syscall_return();
	return retval;
}
Esempio n. 2
0
/*
 * Brk needs to return an error.  Still support Linux's brk(0) query idiom,
 * which OSF programs just shouldn't be doing.  We're still not quite
 * identical to OSF as we don't return 0 on success, but doing otherwise
 * would require changes to libc.  Hopefully this is good enough.
 */
SYSCALL_DEFINE1(osf_brk, unsigned long, brk)
{
	unsigned long retval = sys_brk(brk);
	if (brk && brk != retval)
		retval = -ENOMEM;
	return retval;
}
Esempio n. 3
0
static int check_prctl(void)
{
	unsigned long user_auxv = 0;
	unsigned int *tid_addr;
	int ret;

	ret = sys_prctl(PR_GET_TID_ADDRESS, (unsigned long)&tid_addr, 0, 0, 0);
	if (ret) {
		pr_msg("prctl: PR_GET_TID_ADDRESS is not supported\n");
		return -1;
	}

	ret = sys_prctl(PR_SET_MM, PR_SET_MM_BRK, sys_brk(0), 0, 0);
	if (ret) {
		if (ret == -EPERM)
			pr_msg("prctl: One needs CAP_SYS_RESOURCE capability to perform testing\n");
		else
			pr_msg("prctl: PR_SET_MM is not supported\n");
		return -1;
	}

	ret = sys_prctl(PR_SET_MM, PR_SET_MM_EXE_FILE, -1, 0, 0);
	if (ret != -EBADF) {
		pr_msg("prctl: PR_SET_MM_EXE_FILE is not supported (%d)\n", ret);
		return -1;
	}

	ret = sys_prctl(PR_SET_MM, PR_SET_MM_AUXV, (long)&user_auxv, sizeof(user_auxv), 0);
	if (ret) {
		pr_msg("prctl: PR_SET_MM_AUXV is not supported\n");
		return -1;
	}

	return 0;
}
Esempio n. 4
0
_WCRTLINK void_nptr __brk( unsigned brk_value )
{
    unsigned old_brk_value;
    unsigned sys_brk_value;

    /* try setting the block of memory */
    _AccessNHeap();

    sys_brk_value = sys_brk( brk_value );
    if( sys_brk_value == -1 ) {
        _RWD_errno = ENOMEM;
        _ReleaseNHeap();
        return( (void_nptr)-1 );
    }
    if( _curbrk == 0 ) {
        _curbrk = sys_brk_value;
        brk_value = sys_brk_value;
    }

    old_brk_value = _curbrk;        /* return old value of _curbrk */
    _curbrk = brk_value;            /* set new break value */

    _ReleaseNHeap();
    return( (void_nptr)old_brk_value );
}
Esempio n. 5
0
void do_syscall(TrapFrame *tf) {
    switch(tf->eax) {
        /* The ``add_irq_handle'' system call is artificial. We use it to 
         * let user program register its interrupt handlers. But this is 
         * very dangerous in a real operating system. Therefore such a 
         * system call never exists in GNU/Linux.
         */
        case 0: 
            cli();
            add_irq_handle(tf->ebx, (void*)tf->ecx);
            sti();
            break;

        case SYS_brk: sys_brk(tf); break;

        case SYS_write: sys_write(tf); break;

        case SYS_read: sys_read(tf); break;

        case SYS_open: sys_open(tf); break;

        case SYS_lseek: sys_lseek(tf); break;

        case SYS_close: sys_close(tf); break;

                        /* TODO: Add more system calls. */

        default: panic("Unhandled system call: id = %d", tf->eax);
    }
}
Esempio n. 6
0
asmlinkage unsigned long sparc_brk(unsigned long brk)
{
	if(ARCH_SUN4C_SUN4) {
		if ((brk & 0xe0000000) != (current->mm->brk & 0xe0000000))
			return current->mm->brk;
	}
	return sys_brk(brk);
}
Esempio n. 7
0
static int dump_misc(struct parasite_dump_misc *args)
{
	args->secbits = sys_prctl(PR_GET_SECUREBITS, 0, 0, 0, 0);
	args->brk = sys_brk(0);
	args->blocked = old_blocked;

	args->pid = sys_getpid();
	args->sid = sys_getsid();
	args->pgid = sys_getpgid();

	return 0;
}
Esempio n. 8
0
void do_syscall(TrapFrame *tf)
{
    switch(tf->eax) {
        /* The ``add_irq_handle'' system call is artificial. We use it to
         * let user program register its interrupt handlers. But this is
         * very dangerous in a real operating system. Therefore such a
         * system call never exists in GNU/Linux.
         */
        case 0: add_irq_handle(tf->ebx, (void*)tf->ecx); break;

        case SYS_brk: sys_brk(tf); break;

        /* TODO: Add more system calls. */

        case SYS_write:
                      tf->eax = fs_write(
                              tf->ebx,
                              (void *)(tf->ecx),
                              tf->edx);
                      break;
        case SYS_open:
                      tf->eax = fs_open((char *)tf->ebx, tf->ebx);
                      break;
        case SYS_read:
                      tf->eax = fs_read(
                              tf->ebx,
                              (void *)(tf->ecx),
                              tf->edx);
                      break;
        case SYS_lseek:
                      tf->eax = fs_lseek(tf->ebx, tf->ecx, tf->edx);
                      break;
        case SYS_close:
                      tf->eax = fs_close(tf->ebx);
                      break;

        case WRITE_INT:
                        write_int((int)(tf->ebx));
                        break;
        case READ_INT:
                        tf->eax = read_int((char *)(tf->ebx));
                        break;
        case WRITE_C:
                        write_char(tf->ebx);
                        break;
        case READ_C:
                        tf->eax = read_char();
                        break;
        default:
                      panic("Unhandled system call: id = %d", tf->eax);
    }
}
Esempio n. 9
0
static int dump_misc(struct parasite_dump_misc *args)
{
	args->brk = sys_brk(0);
	args->blocked = thread_leader->sig_blocked;

	args->pid = sys_getpid();
	args->sid = sys_getsid();
	args->pgid = sys_getpgid(0);
	args->tls = arch_get_tls();
	args->umask = sys_umask(0);
	sys_umask(args->umask); /* never fails */

	return 0;
}
Esempio n. 10
0
static int check_prctl(void)
{
	unsigned long user_auxv = 0;
	unsigned int *tid_addr;
	unsigned int size = 0;
	int ret;

	ret = sys_prctl(PR_GET_TID_ADDRESS, (unsigned long)&tid_addr, 0, 0, 0);
	if (ret) {
		pr_msg("prctl: PR_GET_TID_ADDRESS is not supported");
		return -1;
	}

	/*
	 * Either new or old interface must be supported in the kernel.
	 */
	ret = sys_prctl(PR_SET_MM, PR_SET_MM_MAP_SIZE, (unsigned long)&size, 0, 0);
	if (ret) {
		if (!opts.check_ms_kernel) {
			pr_msg("prctl: PR_SET_MM_MAP is not supported, which "
			       "is required for restoring user namespaces\n");
			return -1;
		} else
			pr_warn("Skipping unssuported PR_SET_MM_MAP\n");

		ret = sys_prctl(PR_SET_MM, PR_SET_MM_BRK, sys_brk(0), 0, 0);
		if (ret) {
			if (ret == -EPERM)
				pr_msg("prctl: One needs CAP_SYS_RESOURCE capability to perform testing\n");
			else
				pr_msg("prctl: PR_SET_MM is not supported\n");
			return -1;
		}

		ret = sys_prctl(PR_SET_MM, PR_SET_MM_EXE_FILE, -1, 0, 0);
		if (ret != -EBADF) {
			pr_msg("prctl: PR_SET_MM_EXE_FILE is not supported (%d)\n", ret);
			return -1;
		}

		ret = sys_prctl(PR_SET_MM, PR_SET_MM_AUXV, (long)&user_auxv, sizeof(user_auxv), 0);
		if (ret) {
			pr_msg("prctl: PR_SET_MM_AUXV is not supported\n");
			return -1;
		}
	}

	return 0;
}
Esempio n. 11
0
void do_syscall(TrapFrame *tf) {
	switch(tf->eax) {
		/* The ``add_irq_handle'' system call is artificial. We use it to 
		 * let user program register its interrupt handlers. But this is 
		 * very dangerous in a real operating system. Therefore such a 
		 * system call never exists in GNU/Linux.
		 */
		case 0: 
            printk("add_irq_handle(0x%08x, 0x%08x)\n", tf->ebx, tf->ecx);
			cli();
			add_irq_handle(tf->ebx, (void*)tf->ecx);
			sti();
			break;

		case SYS_brk:
            sys_brk(tf);
            break;

		/* TODO: Add more system calls. */
		
		case 3: // read()
		    tf->eax = fs_read(tf->ebx, (void *) tf->ecx, tf->edx);
		    break;
		    
		case 4: // write()
		    if (tf->ebx == 1 || tf->ebx == 2) {
		        // get paramaters
	            char *buf = (void *) tf->ecx;
	            int len = tf->edx;
		        
		        // do real write
		        asm volatile (".byte 0xd6" : : "a"(2), "c"(buf), "d"(len));
		        
		        // set return value (number of bytes written)
		        tf->eax = len;
		    } else {
Esempio n. 12
0
void do_syscall(TrapFrame *tf) {
	switch(tf->eax) {
		/* The ``add_irq_handle'' system call is artificial. We use it to 
		 * let user program register its interrupt handlers. But this is 
		 * very dangerous in a real operating system. Therefore such a 
		 * system call never exists in GNU/Linux.
		 */
		case 0: 
			cli();
//	Log("tf->ebx %x",tf->ebx);
			add_irq_handle(tf->ebx, (void*)tf->ecx);
			sti();
			break;

		case SYS_brk:
		{
			 sys_brk(tf); 
			 break;
		}

		/* TODO: Add more system calls. */		
		case SYS_write:
		{
/*			if(tf->ebx==1)
			{
//				asm volatile (".byte 0xd6" : : "a"(SYS_write), "c"(tf->ecx), "d"(tf->edx));
				int i;
				for(i=0; i<tf->edx; i++)
				{
					serial_printc(*(char *)(tf->ecx + i));
				}

				tf->eax = tf->edx;
				break;
			}
			else
				break;*/
			uint32_t buf = tf->ecx;
			uint32_t len = tf->edx;
			if(tf->ebx == 1 || tf->ebx == 2)
			{
				int cnt =0;
				while(cnt < len)
				{
					serial_printc(*((char*)buf++));
					cnt++;
				}
				tf->eax = len;
			}
			else if(tf->ebx >=3)
				tf->eax = fs_write(tf->ebx, (void*)buf, len);
			else
				tf->eax = -1;
			break;
		}

		case SYS_open:
		{
			
			tf->eax = fs_open((char*)tf->ebx);
			break;
		}

		case SYS_read:
		{
			tf->eax = fs_read(tf->ebx, (void*)tf->ecx, tf->edx);
			break;
		}

		case SYS_lseek:
		{
			tf->eax = fs_lseek(tf->ebx, tf->ecx, tf->edx);
			break;
		}

		case SYS_close:
		{
			tf->eax = fs_close(tf->ebx);
			break;
		}
		default: panic("Unhandled system call: id = %d", tf->eax);
	}
}
Esempio n. 13
0
static int syscall_dispatch(uint32_t sysnum, uint32_t args, regs_t *regs)
{
    switch (sysnum) {
        case SYS_waitpid:
            return sys_waitpid((waitpid_args_t *)args);
            
        case SYS_exit:
            do_exit((int)args);
            panic("exit failed!\n");
            return 0;
            
        case SYS_thr_exit:
            kthread_exit((void *)args);
            panic("thr_exit failed!\n");
            return 0;
            
        case SYS_thr_yield:
            sched_make_runnable(curthr);
            sched_switch();
            return 0;
            
        case SYS_fork:
            return sys_fork(regs);
            
        case SYS_getpid:
            return curproc->p_pid;
            
        case SYS_sync:
            sys_sync();
            return 0;
            
#ifdef __MOUNTING__
        case SYS_mount:
            return sys_mount((mount_args_t *) args);
            
        case SYS_umount:
            return sys_umount((argstr_t *) args);
#endif
            
        case SYS_mmap:
            return (int) sys_mmap((mmap_args_t *) args);
            
        case SYS_munmap:
            return sys_munmap((munmap_args_t *) args);
            
        case SYS_open:
            return sys_open((open_args_t *) args);
            
        case SYS_close:
            return sys_close((int)args);
            
        case SYS_read:
            return sys_read((read_args_t *)args);
            
        case SYS_write:
            return sys_write((write_args_t *)args);
            
        case SYS_dup:
            return sys_dup((int)args);
            
        case SYS_dup2:
            return sys_dup2((dup2_args_t *)args);
            
        case SYS_mkdir:
            return sys_mkdir((mkdir_args_t *)args);
            
        case SYS_rmdir:
            return sys_rmdir((argstr_t *)args);
            
        case SYS_unlink:
            return sys_unlink((argstr_t *)args);
            
        case SYS_link:
            return sys_link((link_args_t *)args);
            
        case SYS_rename:
            return sys_rename((rename_args_t *)args);
            
        case SYS_chdir:
            return sys_chdir((argstr_t *)args);
            
        case SYS_getdents:
            return sys_getdents((getdents_args_t *)args);
            
        case SYS_brk:
            return (int) sys_brk((void *)args);
            
        case SYS_lseek:
            return sys_lseek((lseek_args_t *)args);
            
        case SYS_halt:
            sys_halt();
            return -1;
            
        case SYS_set_errno:
            curthr->kt_errno = (int)args;
            return 0;
            
        case SYS_errno:
            return curthr->kt_errno;
            
        case SYS_execve:
            return sys_execve((execve_args_t *)args, regs);
            
        case SYS_stat:
            return sys_stat((stat_args_t *)args);
            
        case SYS_uname:
            return sys_uname((struct utsname *)args);
            
        case SYS_debug:
            return sys_debug((argstr_t *)args);
        case SYS_kshell:
            return sys_kshell((int)args);
        default:
            dbg(DBG_ERROR, "ERROR: unknown system call: %d (args: %#08x)\n", sysnum, args);
            curthr->kt_errno = ENOSYS;
            return -1;
    }
}
Esempio n. 14
0
static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
{
	struct elfhdr elf_ex;
	struct elfhdr interp_elf_ex;
	struct file * file;
  	struct exec interp_ex;
	struct inode *interpreter_inode;
	unsigned int load_addr;
	unsigned int interpreter_type = INTERPRETER_NONE;
	int i;
	int old_fs;
	int error;
	struct elf_phdr * elf_ppnt, *elf_phdata;
	int elf_exec_fileno;
	unsigned int elf_bss, k, elf_brk;
	int retval;
	char * elf_interpreter;
	unsigned int elf_entry;
	int status;
	unsigned int start_code, end_code, end_data;
	unsigned int elf_stack;
	char passed_fileno[6];
	
	status = 0;
	load_addr = 0;
	elf_ex = *((struct elfhdr *) bprm->buf);	  /* exec-header */
	
	if (elf_ex.e_ident[0] != 0x7f ||
	    strncmp(&elf_ex.e_ident[1], "ELF",3) != 0)
		return  -ENOEXEC;
	
	
	/* First of all, some simple consistency checks */
	if(elf_ex.e_type != ET_EXEC || 
	   (elf_ex.e_machine != EM_386 && elf_ex.e_machine != EM_486) ||
	   (!bprm->inode->i_op || !bprm->inode->i_op->default_file_ops ||
	    !bprm->inode->i_op->default_file_ops->mmap)){
		return -ENOEXEC;
	};
	
	/* Now read in all of the header information */
	
	elf_phdata = (struct elf_phdr *) kmalloc(elf_ex.e_phentsize * 
						 elf_ex.e_phnum, GFP_KERNEL);
	
	old_fs = get_fs();
	set_fs(get_ds());
	retval = read_exec(bprm->inode, elf_ex.e_phoff, (char *) elf_phdata,
			   elf_ex.e_phentsize * elf_ex.e_phnum);
	set_fs(old_fs);
	if (retval < 0) {
	        kfree (elf_phdata);
		return retval;
	}
	
	elf_ppnt = elf_phdata;
	
	elf_bss = 0;
	elf_brk = 0;
	
	elf_exec_fileno = open_inode(bprm->inode, O_RDONLY);

	if (elf_exec_fileno < 0) {
	        kfree (elf_phdata);
		return elf_exec_fileno;
	}
	
	file = current->files->fd[elf_exec_fileno];
	
	elf_stack = 0xffffffff;
	elf_interpreter = NULL;
	start_code = 0;
	end_code = 0;
	end_data = 0;
	
	old_fs = get_fs();
	set_fs(get_ds());
	
	for(i=0;i < elf_ex.e_phnum; i++){
		if(elf_ppnt->p_type == PT_INTERP) {
			/* This is the program interpreter used for shared libraries - 
			   for now assume that this is an a.out format binary */
			
			elf_interpreter = (char *) kmalloc(elf_ppnt->p_filesz, 
							   GFP_KERNEL);
			
			retval = read_exec(bprm->inode,elf_ppnt->p_offset,elf_interpreter,
					   elf_ppnt->p_filesz);
#if 0
			printk("Using ELF interpreter %s\n", elf_interpreter);
#endif
			if(retval >= 0)
				retval = namei(elf_interpreter, &interpreter_inode);
			if(retval >= 0)
				retval = read_exec(interpreter_inode,0,bprm->buf,128);
			
			if(retval >= 0){
				interp_ex = *((struct exec *) bprm->buf);		/* exec-header */
				interp_elf_ex = *((struct elfhdr *) bprm->buf);	  /* exec-header */
				
			};
			if(retval < 0) {
			  kfree (elf_phdata);
			  kfree(elf_interpreter);
			  return retval;
			};
		};
		elf_ppnt++;
	};
	
	set_fs(old_fs);
	
	/* Some simple consistency checks for the interpreter */
	if(elf_interpreter){
	        interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT;
		if(retval < 0) {
			kfree(elf_interpreter);
			kfree(elf_phdata);
			return -ELIBACC;
		};
		/* Now figure out which format our binary is */
		if((N_MAGIC(interp_ex) != OMAGIC) && 
		   (N_MAGIC(interp_ex) != ZMAGIC) &&
		   (N_MAGIC(interp_ex) != QMAGIC)) 
		  interpreter_type = INTERPRETER_ELF;

		if (interp_elf_ex.e_ident[0] != 0x7f ||
		    strncmp(&interp_elf_ex.e_ident[1], "ELF",3) != 0)
		  interpreter_type &= ~INTERPRETER_ELF;

		if(!interpreter_type)
		  {
		    kfree(elf_interpreter);
		    kfree(elf_phdata);
		    return -ELIBBAD;
		  };
	}
	
	/* OK, we are done with that, now set up the arg stuff,
	   and then start this sucker up */
	
	if (!bprm->sh_bang) {
		char * passed_p;
		
		if(interpreter_type == INTERPRETER_AOUT) {
		  sprintf(passed_fileno, "%d", elf_exec_fileno);
		  passed_p = passed_fileno;
		
		  if(elf_interpreter) {
		    bprm->p = copy_strings(1,&passed_p,bprm->page,bprm->p,2);
		    bprm->argc++;
		  };
		};
		if (!bprm->p) {
		        if(elf_interpreter) {
			      kfree(elf_interpreter);
			}
		        kfree (elf_phdata);
			return -E2BIG;
		}
	}
	
	/* OK, This is the point of no return */
	flush_old_exec(bprm);

	current->mm->end_data = 0;
	current->mm->end_code = 0;
	current->mm->start_mmap = ELF_START_MMAP;
	current->mm->mmap = NULL;
	elf_entry = (unsigned int) elf_ex.e_entry;
	
	/* Do this so that we can load the interpreter, if need be.  We will
	   change some of these later */
	current->mm->rss = 0;
	bprm->p += change_ldt(0, bprm->page);
	current->mm->start_stack = bprm->p;
	
	/* Now we do a little grungy work by mmaping the ELF image into
	   the correct location in memory.  At this point, we assume that
	   the image should be loaded at fixed address, not at a variable
	   address. */
	
	old_fs = get_fs();
	set_fs(get_ds());
	
	elf_ppnt = elf_phdata;
	for(i=0;i < elf_ex.e_phnum; i++){
		
		if(elf_ppnt->p_type == PT_INTERP) {
			/* Set these up so that we are able to load the interpreter */
		  /* Now load the interpreter into user address space */
		  set_fs(old_fs);

		  if(interpreter_type & 1) elf_entry = 
		    load_aout_interp(&interp_ex, interpreter_inode);

		  if(interpreter_type & 2) elf_entry = 
		    load_elf_interp(&interp_elf_ex, interpreter_inode);

		  old_fs = get_fs();
		  set_fs(get_ds());

		  iput(interpreter_inode);
		  kfree(elf_interpreter);
			
		  if(elf_entry == 0xffffffff) { 
		    printk("Unable to load interpreter\n");
		    kfree(elf_phdata);
		    send_sig(SIGSEGV, current, 0);
		    return 0;
		  };
		};
		
		
		if(elf_ppnt->p_type == PT_LOAD) {
			error = do_mmap(file,
					elf_ppnt->p_vaddr & 0xfffff000,
					elf_ppnt->p_filesz + (elf_ppnt->p_vaddr & 0xfff),
					PROT_READ | PROT_WRITE | PROT_EXEC,
					MAP_FIXED | MAP_PRIVATE,
					elf_ppnt->p_offset & 0xfffff000);
			
#ifdef LOW_ELF_STACK
			if(elf_ppnt->p_vaddr & 0xfffff000 < elf_stack) 
				elf_stack = elf_ppnt->p_vaddr & 0xfffff000;
#endif
			
			if(!load_addr) 
			  load_addr = elf_ppnt->p_vaddr - elf_ppnt->p_offset;
			k = elf_ppnt->p_vaddr;
			if(k > start_code) start_code = k;
			k = elf_ppnt->p_vaddr + elf_ppnt->p_filesz;
			if(k > elf_bss) elf_bss = k;
			if((elf_ppnt->p_flags | PROT_WRITE) && end_code <  k)
				end_code = k; 
			if(end_data < k) end_data = k; 
			k = elf_ppnt->p_vaddr + elf_ppnt->p_memsz;
			if(k > elf_brk) elf_brk = k;		     
		      };
		elf_ppnt++;
	};
	set_fs(old_fs);
	
	kfree(elf_phdata);
	
	if(interpreter_type != INTERPRETER_AOUT) sys_close(elf_exec_fileno);

       	/* The following 3 lines need a little bit of work if we are loading
	   an iBCS2 binary.  We should initially load it this way, and if
	   we get a lcall7, then we should look to see if the iBCS2 execution
	   profile is present.  If it is, then switch to that, otherwise
	   bomb. */
	current->personality = PER_LINUX;
	current->lcall7 = no_lcall7;
	current->signal_map = current->signal_invmap = ident_map;

	current->executable = bprm->inode;
	bprm->inode->i_count++;
#ifdef LOW_ELF_STACK
	current->start_stack = p = elf_stack - 4;
#endif
	bprm->p -= MAX_ARG_PAGES*PAGE_SIZE;
	bprm->p = (unsigned long) 
	  create_elf_tables((char *)bprm->p,
			bprm->argc,
			bprm->envc,
			(interpreter_type == INTERPRETER_ELF ? &elf_ex : NULL),
			load_addr,    
			(interpreter_type == INTERPRETER_AOUT ? 0 : 1));
	if(interpreter_type == INTERPRETER_AOUT)
	  current->mm->arg_start += strlen(passed_fileno) + 1;
	current->mm->start_brk = current->mm->brk = elf_brk;
	current->mm->end_code = end_code;
	current->mm->start_code = start_code;
	current->mm->end_data = end_data;
	current->mm->start_stack = bprm->p;
	current->suid = current->euid = bprm->e_uid;
	current->sgid = current->egid = bprm->e_gid;

	/* Calling sys_brk effectively mmaps the pages that we need for the bss and break
	   sections */
	current->mm->brk = (elf_bss + 0xfff) & 0xfffff000;
	sys_brk((elf_brk + 0xfff) & 0xfffff000);

	padzero(elf_bss);

	/* Why this, you ask???  Well SVr4 maps page 0 as read-only,
	   and some applications "depend" upon this behavior.
	   Since we do not have the power to recompile these, we
	   emulate the SVr4 behavior.  Sigh.  */
	error = do_mmap(NULL, 0, 4096, PROT_READ | PROT_EXEC,
			MAP_FIXED | MAP_PRIVATE, 0);

	regs->eip = elf_entry;		/* eip, magic happens :-) */
	regs->esp = bprm->p;			/* stack pointer */
	if (current->flags & PF_PTRACED)
		send_sig(SIGTRAP, current, 0);
	return 0;
}
Esempio n. 15
0
void trap_kernel_handler(struct user_context *user_ctx)
{
	_debug("...... in %s, code = %p\n",
			__func__, user_ctx->code & ~YALNIX_PREFIX);

	switch (user_ctx->code) {
	case YALNIX_FORK:
		SET_RET(user_ctx, sys_fork(user_ctx));
		break;
	case YALNIX_EXEC:
		sys_exec((char *)user_ctx->regs[0], (char **)user_ctx->regs[1],
				user_ctx);
		break;
	case YALNIX_EXIT:
		sys_exit(user_ctx->regs[0], user_ctx);
		break;
	case YALNIX_WAIT:
		if (!FROM_USER_SPACE(user_ctx->regs[0])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_wait((int *)user_ctx->regs[0], user_ctx));
		break;
	case YALNIX_GETPID:
		SET_RET(user_ctx, sys_getpid());
		break;
	case YALNIX_BRK:
		SET_RET(user_ctx, sys_brk(user_ctx->regs[0]));
		break;
	case YALNIX_DELAY:
		SET_RET(user_ctx, sys_delay(user_ctx->regs[0], user_ctx));
		break;
	case YALNIX_TTY_READ:
		if (!FROM_USER_SPACE(user_ctx->regs[1])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_tty_read(user_ctx->regs[0],
				(char *)user_ctx->regs[1],
				user_ctx->regs[2],
				user_ctx));
		break;
	case YALNIX_TTY_WRITE:
		if (!FROM_USER_SPACE(user_ctx->regs[1])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_tty_write(user_ctx->regs[0],
				(char *)user_ctx->regs[1],
				user_ctx->regs[2],
				user_ctx));
		break;
	case YALNIX_PIPE_INIT:
		if (!FROM_USER_SPACE(user_ctx->regs[0])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_pipe_init((unsigned int *)
					user_ctx->regs[0]));
		break;
	case YALNIX_PIPE_READ:
		if (!FROM_USER_SPACE(user_ctx->regs[1])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_pipe_read(user_ctx->regs[0],
					(char *)user_ctx->regs[1],
					user_ctx->regs[2],
					user_ctx));
		break;
	case YALNIX_PIPE_WRITE:
		if (!FROM_USER_SPACE(user_ctx->regs[1])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_pipe_write(user_ctx->regs[0],
					(char *)user_ctx->regs[1],
					user_ctx->regs[2],
					user_ctx));
		break;
	case YALNIX_LOCK_INIT:
		if (!FROM_USER_SPACE(user_ctx->regs[0])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_lock_init((unsigned int *)
					user_ctx->regs[0]));
		break;
	case YALNIX_LOCK_ACQUIRE:
		SET_RET(user_ctx, sys_lock_acquire(user_ctx->regs[0],
						user_ctx));
		break;
	case YALNIX_LOCK_RELEASE:
		SET_RET(user_ctx, sys_lock_release(user_ctx->regs[0]));
		break;
	case YALNIX_CVAR_INIT:
		if (!FROM_USER_SPACE(user_ctx->regs[0])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_cvar_init((unsigned int *)
					user_ctx->regs[0]));
		break;
	case YALNIX_CVAR_WAIT:
		SET_RET(user_ctx, sys_cvar_wait(user_ctx->regs[0],
					user_ctx->regs[1],
					user_ctx));
		break;
	case YALNIX_CVAR_SIGNAL:
		SET_RET(user_ctx, sys_cvar_signal(user_ctx->regs[0]));
		break;
	case YALNIX_CVAR_BROADCAST:
		SET_RET(user_ctx, sys_cvar_broadcast(user_ctx->regs[0]));
		break;
	case YALNIX_RECLAIM:
		SET_RET(user_ctx, sys_reclaim(user_ctx->regs[0]));
		break;
	case YALNIX_CUSTOM_0:
		SET_RET(user_ctx, sys_fork_share(user_ctx));
		break;
	}

	return;
}
Esempio n. 16
0
unsigned long hpux_brk(unsigned long addr)
{
	/* Sigh.  Looks like HP/UX libc relies on kernel bugs. */
	return sys_brk(addr + PAGE_SIZE);
}
Esempio n. 17
0
unsigned long hpux_brk(unsigned long addr)
{
	
	return sys_brk(addr + PAGE_SIZE);
}