Ejemplo n.º 1
0
SYSCALL_DEFINE2(setregid16, old_gid_t, rgid, old_gid_t, egid)
{
	long ret = sys_setregid(low2highgid(rgid), low2highgid(egid));
	/* avoid REGPARM breakage on x86: */
	asmlinkage_protect(2, ret, rgid, egid);
	return ret;
}
Ejemplo n.º 2
0
Archivo: uid16.c Proyecto: 274914765/C
asmlinkage long sys_setregid16(old_gid_t rgid, old_gid_t egid)
{
    long ret = sys_setregid(low2highgid(rgid), low2highgid(egid));
    /* avoid REGPARM breakage on x86: */
    asmlinkage_protect(2, ret, rgid, egid);
    return ret;
}
Ejemplo n.º 3
0
static int fn(void *d)
{
    struct l4fdx_client *client = d;
    int err;

    err = sys_setregid(client->gid, client->gid);
    err = sys_setreuid(client->uid, client->uid);
    err = sys_setsid();

    if (client->capname)
        snprintf(current->comm, sizeof(current->comm),
                 "l4xfdx-%s", client->capname);
    else
        snprintf(current->comm, sizeof(current->comm),
                 "l4xfdx-%lx", client->cap >> L4_CAP_SHIFT);
    current->comm[sizeof(current->comm) - 1] = 0;

    set_user_nice(current, -20);

    while (!should_stop || !list_empty(&client->req_list)) {
        struct internal_request *r;

        wait_event_interruptible(client->event,
                                 !list_empty(&client->req_list)
                                 || should_stop);

        r = pop_request(client->srv_obj);

        switch (r->type) {
        case L4FS_REQ_OPEN:
            fn_open(client->srv_obj, r);
            break;
        case L4FS_REQ_READ:
            fn_read(client->srv_obj, r);
            break;
        case L4FS_REQ_WRITE:
            fn_write(client->srv_obj, r);
            break;
        case L4FS_REQ_CLOSE:
            fn_close(client->srv_obj, r);
            break;
        case L4FS_REQ_FSTAT64:
            fn_fstat64(client->srv_obj, r);
            break;
        default:
            pr_err("l4fdx: Invalid type=%d\n", r->type);
            break;
        }
    }

    return 0;
}
Ejemplo n.º 4
0
asmlinkage long sys_setregid16(old_gid_t rgid, old_gid_t egid)
{
	return sys_setregid(low2highgid(rgid), low2highgid(egid));
}
Ejemplo n.º 5
0
asmlinkage long sys32_setregid16(u16 rgid, u16 egid)
{
	return sys_setregid(low2highgid(rgid), low2highgid(egid));
}
Ejemplo n.º 6
0
int
so_socksys(struct socksysreq *req)
{
	int err = -EINVAL;
	int cmd = req->args[0];

	if ((1 << cmd) & ((1 << SO_ACCEPT) | (1 << SO_BIND) | (1 << SO_CONNECT) |
			  (1 << SO_GETPEERNAME) | (1 << SO_GETSOCKNAME) | (1 << SO_GETSOCKOPT) |
			  (1 << SO_LISTEN) | (1 << SO_RECV) | (1 << SO_RECVFROM) | (1 << SO_SEND) |
			  (1 << SO_SENDTO) | (1 << SO_SETSOCKOPT) | (1 << SO_SHUTDOWN) |
			  (1 << SO_RECVMSG) | (1 << SO_SENDMSG))) {
		int fd = req->args[1];

		(void) fd;
		/* These are all socket related and accept a file (socket) descriptor as their
		   first argument.  In situations where we are incapable of providing back a real
		   socket, we must here first distinguish if the file descriptor corresponds to a
		   socket or a stream. */
#if 0
		if (it_is_a_socket) {
#endif
			/* In this case, we have a real socket from the operating system's
			   perspective and we can simply pass the arguments to the appropriate
			   system call. */
#if 0
			switch (cmd) {
			case SO_ACCEPT:
				/* FIXME: 32/64 conversion */
				err = sys_accept(fd, (struct sockaddr *) req->args[2],
						 req->args[3]);
				break;
			case SO_BIND:
				/* FIXME: 32/64 conversion */
				err = sys_bind(fd, (struct sockaddr *) req->args[2], req->args[3]);
				break;
			case SO_CONNECT:
				/* FIXME: 32/64 conversion */
				err = sys_connect(fd, (struct sockaddr *) req->args[2],
						  req->args[3]);
				break;
			case SO_GETPEERNAME:
				/* FIXME: 32/64 conversion */
				err = sys_getpeername(fd, (struct sockaddr *) req->args[2],
						      (int *) req->args[3]);
				break;
			case SO_GETSOCKNAME:
				/* FIXME: 32/64 conversion */
				err = sys_getsockname(fd, (struct sockaddr *) req->args[2],
						      (int *) req->args[3]);
				break;
			case SO_GETSOCKOPT:
				/* FIXME: 32/64 conversion */
				err = sys_getsockopt(fd, req->args[2], req->args[3],
						     (char *) req->args[4], (int *) req->args[5]);
				break;
			case SO_LISTEN:
				/* FIXME: 32/64 conversion */
				err = sys_listen(fd, req->args[2]);
				break;
			case SO_RECV:
				/* FIXME: 32/64 conversion */
				err = sys_recv(fd, (void *) req->args[2], req->args[3],
					       req->args[4]);
				break;
			case SO_RECVFROM:
				/* FIXME: 32/64 conversion */
				err = sys_recvfrom(fd, (void *) req->args[2], req->args[3],
						   req->args[4], (struct sockaddr *) req->args[5],
						   (int *) req->args[6]);
				break;
			case SO_SEND:
				/* FIXME: 32/64 conversion */
				err = sys_send(fd, (void *) req->args[2], req->args[3],
					       req->args[4]);
				break;
			case SO_SENDTO:
				/* FIXME: 32/64 conversion */
				err = sys_sendto(fd, (void *) req->args[2], req->args[3],
						 req->args[4], (struct sockaddr *) req->args[5],
						 req->args[6]);
				break;
			case SO_SETSOCKOPT:
				/* FIXME: 32/64 conversion */
				err = sys_setsockopt(fd, req->args[2], req->args[3],
						     (char *) req->args[4], req->args[5]);
				break;
			case SO_SHUTDOWN:
				/* FIXME: 32/64 conversion */
				err = sys_shutdown(fd, req->args[2]);
				break;
			case SO_RECVMSG:
				/* FIXME: 32/64 conversion */
				err = sys_recvmsg(fd, (struct msghdr *) req->args[2], req->args[3]);
				break;
			case SO_SENDMSG:
				/* FIXME: 32/64 conversion */
				err = sys_sendmsg(fd, (struct msghdr *) req->args[2], req->args[3]);
				break;
			}
#endif
#if 0
		} else {
			/* In this case, we do not have a real socket, but have a TPI stream from
			   the operating system's perspective, and we will directly call the
			   associated TPI routine. */
			switch (cmd) {
			case SO_ACCEPT:
				/* FIXME: 32/64 conversion */
				err = tpi_accept(fd, (struct sockaddr *) req->args[2],
						 req->args[3]);
				break;
			case SO_BIND:
				/* FIXME: 32/64 conversion */
				err = tpi_bind(fd, (struct sockaddr *) req->args[2], req->args[3]);
				break;
			case SO_CONNECT:
				/* FIXME: 32/64 conversion */
				err = tpi_connect(fd, (struct sockaddr *) req->args[2],
						  req->args[3]);
				break;
			case SO_GETPEERNAME:
				/* FIXME: 32/64 conversion */
				err = tpi_getpeername(fd, (struct sockaddr *) req->args[2],
						      (int *) req->args[3]);
				break;
			case SO_GETSOCKNAME:
				/* FIXME: 32/64 conversion */
				err = tpi_getsockname(fd, (struct sockaddr *) req->args[2],
						      (int *) req->args[3]);
				break;
			case SO_GETSOCKOPT:
				/* FIXME: 32/64 conversion */
				err = tpi_getsockopt(fd, req->args[2], req->args[3],
						     (char *) req->args[4], (int *) req->args[5]);
				break;
			case SO_LISTEN:
				/* FIXME: 32/64 conversion */
				err = tpi_listen(fd, req->args[2]);
				break;
			case SO_RECV:
				/* FIXME: 32/64 conversion */
				err = tpi_recv(fd, (void *) req->args[2], req->args[3],
					       req->args[4]);
				break;
			case SO_RECVFROM:
				/* FIXME: 32/64 conversion */
				err = tpi_recvfrom(fd, (void *) req->args[2], req->args[3],
						   req->args[4], (struct sockaddr *) req->args[5],
						   (int *) req->args[6]);
				break;
			case SO_SEND:
				/* FIXME: 32/64 conversion */
				err = tpi_send(fd, (void *) req->args[2], req->args[3],
					       req->args[4]);
				break;
			case SO_SENDTO:
				/* FIXME: 32/64 conversion */
				err = tpi_sendto(fd, (void *) req->args[2], req->args[3],
						 req->args[4], (struct sockaddr *) req->args[5],
						 req->args[6]);
				break;
			case SO_SETSOCKOPT:
				/* FIXME: 32/64 conversion */
				err = tpi_setsockopt(fd, req->args[2], req->args[3],
						     (char *) req->args[4], req->args[5]);
				break;
			case SO_SHUTDOWN:
				/* FIXME: 32/64 conversion */
				err = tpi_shutdown(fd, req->args[2]);
				break;
			case SO_RECVMSG:
				/* FIXME: 32/64 conversion */
				err = tpi_recvmsg(fd, (struct msghdr *) req->args[2], req->args[3]);
				break;
			case SO_SENDMSG:
				/* FIXME: 32/64 conversion */
				err = tpi_sendmsg(fd, (struct msghdr *) req->args[2], req->args[3]);
				break;
			}
		}
#endif
	}
	if ((1 << cmd) & ((1 << SO_SOCKET) | (1 << SO_SOCKPAIR) | (1 << SO_SELECT) |
			  (1 << SO_GETIPDOMAIN) | (1 << SO_SETIPDOMAIN) | (1 << SO_ADJTIME) |
			  (1 << SO_SETREUID) | (1 << SO_SETREGID) | (1 << SO_GETTIME) |
			  (1 << SO_SETTIME) | (1 << SO_GETITIMER) | (1 << SO_SETITIMER))) {
		/* These are BSD compatibiltiy functions and are how we create sockets in the first
		   place.  The BSD compatibility functions all have system calls in Linux, but we
		   provide them for backward compatibility (to what!?). */
#if 0
		switch (cmd) {
		case SO_SOCKET:
			/* FIXME: 32/64 conversion */
			/* XXX: don't think so..., after checking for a stream */
			err = sys_socket(req->args[1], req->args[2], req->args[3]);
			break;
		case SO_SOCKPAIR:
			/* FIXME: 32/64 conversion */
			/* XXX: don't think so..., after checking for a stream */
			err = sys_socketpair(req->args[1], req->args[2], req->args[3],
					     (int *) req->args[4]);
			err = -EOPNOTSUPP;
			break;
		case SO_SELECT:
			/* FIXME: 32/64 conversion */
			err = sys_select(req->args[1], (fd_set *) req->args[2],
					 (fd_set *) req->args[3], (fd_set *) req->args[4],
					 (struct timeval *) req->args[5]);
			break;
		case SO_GETIPDOMAIN:
			/* FIXME: 32/64 conversion */
			todo(("Process SO_GETIPDOMAIN for compatibility.\n"));
			/* does not exist in Linux, need to use sys_newuname and copy the
			   domainname portion */
			err = -ENOSYS;
			break;
		case SO_SETIPDOMAIN:
			/* FIXME: 32/64 conversion */
			err = sys_setdomainname((char *) req->args[1], req->args[2]);
			break;
		case SO_ADJTIME:
			/* FIXME: 32/64 conversion */
			err = sys_admtimex((struct timex *) req->args[1]);
			break;
		case SO_SETREUID:
			/* FIXME: 32/64 conversion */
			err = sys_setreuid(req->args[1], req->args[2]);
			break;
		case SO_SETREGID:
			/* FIXME: 32/64 conversion */
			err = sys_setregid(req->args[1], req->args[2]);
			break;
		case SO_GETTIME:
			/* FIXME: 32/64 conversion */
			err = sys_gettimeofday((struct timeval *) req->args[1],
					       (struct timezone *) req->args[2]);
			break;
		case SO_SETTIME:
			/* FIXME: 32/64 conversion */
			err = sys_settimeofday((struct timeval *) req->args[1],
					       (struct timezone *) req->args[2]);
			break;
		case SO_GETITIMER:
			/* FIXME: 32/64 conversion */
			err = sys_getitimer(req->args[1], (struct itimerval *) req->args[2]);
			break;
		case SO_SETITIMER:
			/* FIXME: 32/64 conversion */
			err = sys_getitimer(req->args[1], (struct itimerval *) req->args[2],
					    (struct itimerval *) req->args[3]);
			break;
		}
#endif
	}

	return (err);
}
Ejemplo n.º 7
0
int sys_setgid(int gid)
{
	return(sys_setregid(gid, gid));
}
Ejemplo n.º 8
0
void SysCalls::sys_setregid32(CONTEXT& ctx)
{
	sys_setregid(ctx);
}