X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fsparc64%2Fsolaris%2Fioctl.c;h=b0d12032b1e16f371376f8d6ae09007a3388a31c;hb=9bf4aaab3e101692164d49b7ca357651eb691cb6;hp=28f60ab100540d8677391e809550773d84f335fb;hpb=db216c3d5e4c040e557a50f8f5d35d5c415e8c1c;p=linux-2.6.git diff --git a/arch/sparc64/solaris/ioctl.c b/arch/sparc64/solaris/ioctl.c index 28f60ab10..b0d12032b 100644 --- a/arch/sparc64/solaris/ioctl.c +++ b/arch/sparc64/solaris/ioctl.c @@ -39,10 +39,10 @@ extern asmlinkage int compat_sys_ioctl(unsigned int fd, unsigned int cmd, u32 arg); asmlinkage int solaris_ioctl(unsigned int fd, unsigned int cmd, u32 arg); -extern int timod_putmsg(unsigned int fd, char *ctl_buf, int ctl_len, - char *data_buf, int data_len, int flags); -extern int timod_getmsg(unsigned int fd, char *ctl_buf, int ctl_maxlen, int *ctl_len, - char *data_buf, int data_maxlen, int *data_len, int *flags); +extern int timod_putmsg(unsigned int fd, char __user *ctl_buf, int ctl_len, + char __user *data_buf, int data_len, int flags); +extern int timod_getmsg(unsigned int fd, char __user *ctl_buf, int ctl_maxlen, int __user *ctl_len, + char __user *data_buf, int data_maxlen, int __user *data_len, int *flags); /* termio* stuff {{{ */ @@ -117,16 +117,17 @@ static u32 linux_to_solaris_cflag(u32 cflag) static inline int linux_to_solaris_termio(unsigned int fd, unsigned int cmd, u32 arg) { + struct solaris_termio __user *p = A(arg); int ret; - ret = sys_ioctl(fd, cmd, A(arg)); + ret = sys_ioctl(fd, cmd, (unsigned long)p); if (!ret) { u32 cflag; - if (__get_user (cflag, &((struct solaris_termio *)A(arg))->c_cflag)) + if (__get_user (cflag, &p->c_cflag)) return -EFAULT; cflag = linux_to_solaris_cflag(cflag); - if (__put_user (cflag, &((struct solaris_termio *)A(arg))->c_cflag)) + if (__put_user (cflag, &p->c_cflag)) return -EFAULT; } return ret; @@ -138,7 +139,7 @@ static int solaris_to_linux_termio(unsigned int fd, unsigned int cmd, u32 arg) struct solaris_termio s; mm_segment_t old_fs = get_fs(); - if (copy_from_user (&s, (struct solaris_termio *)A(arg), sizeof(struct solaris_termio))) + if (copy_from_user (&s, (struct solaris_termio __user *)A(arg), sizeof(struct solaris_termio))) return -EFAULT; s.c_cflag = solaris_to_linux_cflag(s.c_cflag); set_fs(KERNEL_DS); @@ -157,12 +158,13 @@ static inline int linux_to_solaris_termios(unsigned int fd, unsigned int cmd, u3 ret = sys_ioctl(fd, cmd, (unsigned long)&s); set_fs(old_fs); if (!ret) { - if (put_user (s.c_iflag, &((struct solaris_termios *)A(arg))->c_iflag) || - __put_user (s.c_oflag, &((struct solaris_termios *)A(arg))->c_oflag) || - __put_user (linux_to_solaris_cflag(s.c_cflag), &((struct solaris_termios *)A(arg))->c_cflag) || - __put_user (s.c_lflag, &((struct solaris_termios *)A(arg))->c_lflag) || - __copy_to_user (((struct solaris_termios *)A(arg))->c_cc, s.c_cc, 16) || - __clear_user (((struct solaris_termios *)A(arg))->c_cc + 16, 2)) + struct solaris_termios __user *p = A(arg); + if (put_user (s.c_iflag, &p->c_iflag) || + __put_user (s.c_oflag, &p->c_oflag) || + __put_user (linux_to_solaris_cflag(s.c_cflag), &p->c_cflag) || + __put_user (s.c_lflag, &p->c_lflag) || + __copy_to_user (p->c_cc, s.c_cc, 16) || + __clear_user (p->c_cc + 16, 2)) return -EFAULT; } return ret; @@ -172,17 +174,18 @@ static int solaris_to_linux_termios(unsigned int fd, unsigned int cmd, u32 arg) { int ret; struct solaris_termios s; + struct solaris_termios __user *p = A(arg); mm_segment_t old_fs = get_fs(); set_fs(KERNEL_DS); ret = sys_ioctl(fd, TCGETS, (unsigned long)&s); set_fs(old_fs); if (ret) return ret; - if (put_user (s.c_iflag, &((struct solaris_termios *)A(arg))->c_iflag) || - __put_user (s.c_oflag, &((struct solaris_termios *)A(arg))->c_oflag) || - __put_user (s.c_cflag, &((struct solaris_termios *)A(arg))->c_cflag) || - __put_user (s.c_lflag, &((struct solaris_termios *)A(arg))->c_lflag) || - __copy_from_user (s.c_cc, ((struct solaris_termios *)A(arg))->c_cc, 16)) + if (put_user (s.c_iflag, &p->c_iflag) || + __put_user (s.c_oflag, &p->c_oflag) || + __put_user (s.c_cflag, &p->c_cflag) || + __put_user (s.c_lflag, &p->c_lflag) || + __copy_from_user (s.c_cc, p->c_cc, 16)) return -EFAULT; s.c_cflag = solaris_to_linux_cflag(s.c_cflag); set_fs(KERNEL_DS); @@ -305,7 +308,7 @@ static inline int solaris_sockmod(unsigned int fd, unsigned int cmd, u32 arg) case 109: /* SI_SOCKPARAMS */ { struct solaris_si_sockparams si; - if (copy_from_user (&si, (struct solaris_si_sockparams *) A(arg), sizeof(si))) + if (copy_from_user (&si, A(arg), sizeof(si))) return (EFAULT << 8) | TSYSERR; /* Should we modify socket ino->socket_i.ops and type? */ @@ -314,6 +317,7 @@ static inline int solaris_sockmod(unsigned int fd, unsigned int cmd, u32 arg) case 110: /* SI_GETUDATA */ { int etsdusize, servtype; + struct solaris_si_udata __user *p = A(arg); switch (SOCKET_I(ino)->type) { case SOCK_STREAM: etsdusize = 1; @@ -324,23 +328,24 @@ static inline int solaris_sockmod(unsigned int fd, unsigned int cmd, u32 arg) servtype = 3; break; } - if (put_user(16384, &((struct solaris_si_udata *)A(arg))->tidusize) || - __put_user(sizeof(struct sockaddr), &((struct solaris_si_udata *)A(arg))->addrsize) || - __put_user(-1, &((struct solaris_si_udata *)A(arg))->optsize) || - __put_user(etsdusize, &((struct solaris_si_udata *)A(arg))->etsdusize) || - __put_user(servtype, &((struct solaris_si_udata *)A(arg))->servtype) || - __put_user(0, &((struct solaris_si_udata *)A(arg))->so_state) || - __put_user(0, &((struct solaris_si_udata *)A(arg))->so_options) || - __put_user(16384, &((struct solaris_si_udata *)A(arg))->tsdusize) || - __put_user(SOCKET_I(ino)->ops->family, &((struct solaris_si_udata *)A(arg))->sockparams.sp_family) || - __put_user(SOCKET_I(ino)->type, &((struct solaris_si_udata *)A(arg))->sockparams.sp_type) || - __put_user(SOCKET_I(ino)->ops->family, &((struct solaris_si_udata *)A(arg))->sockparams.sp_protocol)) + if (put_user(16384, &p->tidusize) || + __put_user(sizeof(struct sockaddr), &p->addrsize) || + __put_user(-1, &p->optsize) || + __put_user(etsdusize, &p->etsdusize) || + __put_user(servtype, &p->servtype) || + __put_user(0, &p->so_state) || + __put_user(0, &p->so_options) || + __put_user(16384, &p->tsdusize) || + __put_user(SOCKET_I(ino)->ops->family, &p->sockparams.sp_family) || + __put_user(SOCKET_I(ino)->type, &p->sockparams.sp_type) || + __put_user(SOCKET_I(ino)->ops->family, &p->sockparams.sp_protocol)) return (EFAULT << 8) | TSYSERR; return 0; } case 101: /* O_SI_GETUDATA */ { int etsdusize, servtype; + struct solaris_o_si_udata __user *p = A(arg); switch (SOCKET_I(ino)->type) { case SOCK_STREAM: etsdusize = 1; @@ -351,14 +356,14 @@ static inline int solaris_sockmod(unsigned int fd, unsigned int cmd, u32 arg) servtype = 3; break; } - if (put_user(16384, &((struct solaris_o_si_udata *)A(arg))->tidusize) || - __put_user(sizeof(struct sockaddr), &((struct solaris_o_si_udata *)A(arg))->addrsize) || - __put_user(-1, &((struct solaris_o_si_udata *)A(arg))->optsize) || - __put_user(etsdusize, &((struct solaris_o_si_udata *)A(arg))->etsdusize) || - __put_user(servtype, &((struct solaris_o_si_udata *)A(arg))->servtype) || - __put_user(0, &((struct solaris_o_si_udata *)A(arg))->so_state) || - __put_user(0, &((struct solaris_o_si_udata *)A(arg))->so_options) || - __put_user(16384, &((struct solaris_o_si_udata *)A(arg))->tsdusize)) + if (put_user(16384, &p->tidusize) || + __put_user(sizeof(struct sockaddr), &p->addrsize) || + __put_user(-1, &p->optsize) || + __put_user(etsdusize, &p->etsdusize) || + __put_user(servtype, &p->servtype) || + __put_user(0, &p->so_state) || + __put_user(0, &p->so_options) || + __put_user(16384, &p->tsdusize)) return (EFAULT << 8) | TSYSERR; return 0; } @@ -375,7 +380,7 @@ static inline int solaris_sockmod(unsigned int fd, unsigned int cmd, u32 arg) } static inline int solaris_timod(unsigned int fd, unsigned int cmd, u32 arg, - int len, int *len_p) + int len, int __user *len_p) { int ret; @@ -385,25 +390,25 @@ static inline int solaris_timod(unsigned int fd, unsigned int cmd, u32 arg, int i; u32 prim; SOLD("TI_OPMGMT entry"); - ret = timod_putmsg(fd, (char *)A(arg), len, NULL, -1, 0); + ret = timod_putmsg(fd, A(arg), len, NULL, -1, 0); SOLD("timod_putmsg() returned"); if (ret) return (-ret << 8) | TSYSERR; i = MSG_HIPRI; SOLD("calling timod_getmsg()"); - ret = timod_getmsg(fd, (char *)A(arg), len, len_p, NULL, -1, NULL, &i); + ret = timod_getmsg(fd, A(arg), len, len_p, NULL, -1, NULL, &i); SOLD("timod_getmsg() returned"); if (ret) return (-ret << 8) | TSYSERR; SOLD("ret ok"); - if (get_user(prim, (u32 *)A(arg))) + if (get_user(prim, (u32 __user *)A(arg))) return (EFAULT << 8) | TSYSERR; SOLD("got prim"); if (prim == T_ERROR_ACK) { u32 tmp, tmp2; SOLD("prim is T_ERROR_ACK"); - if (get_user(tmp, (u32 *)A(arg)+3) || - get_user(tmp2, (u32 *)A(arg)+2)) + if (get_user(tmp, (u32 __user *)A(arg)+3) || + get_user(tmp2, (u32 __user *)A(arg)+2)) return (EFAULT << 8) | TSYSERR; return (tmp2 << 8) | tmp; } @@ -415,26 +420,26 @@ static inline int solaris_timod(unsigned int fd, unsigned int cmd, u32 arg, int i; u32 prim; SOLD("TI_BIND entry"); - ret = timod_putmsg(fd, (char *)A(arg), len, NULL, -1, 0); + ret = timod_putmsg(fd, A(arg), len, NULL, -1, 0); SOLD("timod_putmsg() returned"); if (ret) return (-ret << 8) | TSYSERR; len = 1024; /* Solaris allows arbitrary return size */ i = MSG_HIPRI; SOLD("calling timod_getmsg()"); - ret = timod_getmsg(fd, (char *)A(arg), len, len_p, NULL, -1, NULL, &i); + ret = timod_getmsg(fd, A(arg), len, len_p, NULL, -1, NULL, &i); SOLD("timod_getmsg() returned"); if (ret) return (-ret << 8) | TSYSERR; SOLD("ret ok"); - if (get_user(prim, (u32 *)A(arg))) + if (get_user(prim, (u32 __user *)A(arg))) return (EFAULT << 8) | TSYSERR; SOLD("got prim"); if (prim == T_ERROR_ACK) { u32 tmp, tmp2; SOLD("prim is T_ERROR_ACK"); - if (get_user(tmp, (u32 *)A(arg)+3) || - get_user(tmp2, (u32 *)A(arg)+2)) + if (get_user(tmp, (u32 __user *)A(arg)+3) || + get_user(tmp2, (u32 __user *)A(arg)+2)) return (EFAULT << 8) | TSYSERR; return (tmp2 << 8) | tmp; } @@ -444,7 +449,7 @@ static inline int solaris_timod(unsigned int fd, unsigned int cmd, u32 arg, SOLD("OK_ACK requested"); i = MSG_HIPRI; SOLD("calling timod_getmsg()"); - ret = timod_getmsg(fd, (char *)A(arg), len, len_p, NULL, -1, NULL, &i); + ret = timod_getmsg(fd, A(arg), len, len_p, NULL, -1, NULL, &i); SOLD("timod_getmsg() returned"); if (ret) return (-ret << 8) | TSYSERR; @@ -491,7 +496,7 @@ static inline int solaris_S(struct file *filp, unsigned int fd, unsigned int cmd return -ENOSYS; case 2: /* I_PUSH */ { - p = getname ((char *)A(arg)); + p = getname (A(arg)); if (IS_ERR (p)) return PTR_ERR(p); ret = -EINVAL; @@ -520,14 +525,14 @@ static inline int solaris_S(struct file *filp, unsigned int fd, unsigned int cmd const char *p; if (sock->modcount <= 0) return -EINVAL; p = module_table[(unsigned)sock->module[sock->modcount]].name; - if (copy_to_user ((char *)A(arg), p, strlen(p))) + if (copy_to_user (A(arg), p, strlen(p))) return -EFAULT; return 0; } case 5: /* I_FLUSH */ return 0; case 8: /* I_STR */ - if (copy_from_user(&si, (struct strioctl *)A(arg), sizeof(struct strioctl))) + if (copy_from_user(&si, A(arg), sizeof(struct strioctl))) return -EFAULT; /* We ignore what module is actually at the top of stack. */ switch ((si.cmd >> 8) & 0xff) { @@ -535,7 +540,7 @@ static inline int solaris_S(struct file *filp, unsigned int fd, unsigned int cmd return solaris_sockmod(fd, si.cmd, si.data); case 'T': return solaris_timod(fd, si.cmd, si.data, si.len, - &((struct strioctl*)A(arg))->len); + &((struct strioctl __user *)A(arg))->len); default: return solaris_ioctl(fd, si.cmd, si.data); } @@ -551,7 +556,7 @@ static inline int solaris_S(struct file *filp, unsigned int fd, unsigned int cmd case 11: /* I_FIND */ { int i; - p = getname ((char *)A(arg)); + p = getname (A(arg)); if (IS_ERR (p)) return PTR_ERR(p); ret = 0; @@ -580,7 +585,7 @@ static inline int solaris_s(unsigned int fd, unsigned int cmd, u32 arg) return 0; /* We don't support them */ case 1: /* SIOCGHIWAT */ case 3: /* SIOCGLOWAT */ - if (put_user (0, (u32 *)A(arg))) + if (put_user (0, (u32 __user *)A(arg))) return -EFAULT; return 0; /* Lie */ case 7: /* SIOCATMARK */ @@ -663,7 +668,7 @@ static inline int solaris_i(unsigned int fd, unsigned int cmd, u32 arg) args); set_fs(old_fs); if (ret >= 0) { - if (copy_to_user((char *)A(arg), &uaddr, uaddr_len)) + if (copy_to_user(A(arg), &uaddr, uaddr_len)) return -EFAULT; } return ret; @@ -681,7 +686,7 @@ static inline int solaris_i(unsigned int fd, unsigned int cmd, u32 arg) for (d = dev_base; d; d = d->next) i++; read_unlock_bh(&dev_base_lock); - if (put_user (i, (int *)A(arg))) + if (put_user (i, (int __user *)A(arg))) return -EFAULT; return 0; }