Commit ad1dc395 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: atm annotation (core)

ATM core annotated; ATM drivers will go in the next patch, here we only
annotated their method prototypes
parent df127be5
...@@ -232,7 +232,7 @@ static __inline__ int atmpvc_addr_in_use(struct sockaddr_atmpvc addr) ...@@ -232,7 +232,7 @@ static __inline__ int atmpvc_addr_in_use(struct sockaddr_atmpvc addr)
struct atmif_sioc { struct atmif_sioc {
int number; int number;
int length; int length;
void *arg; void __user *arg;
}; };
typedef unsigned short atm_backend_t; typedef unsigned short atm_backend_t;
......
...@@ -351,11 +351,11 @@ struct atmdev_ops { /* only send is required */ ...@@ -351,11 +351,11 @@ struct atmdev_ops { /* only send is required */
void (*dev_close)(struct atm_dev *dev); void (*dev_close)(struct atm_dev *dev);
int (*open)(struct atm_vcc *vcc); int (*open)(struct atm_vcc *vcc);
void (*close)(struct atm_vcc *vcc); void (*close)(struct atm_vcc *vcc);
int (*ioctl)(struct atm_dev *dev,unsigned int cmd,void *arg); int (*ioctl)(struct atm_dev *dev,unsigned int cmd,void __user *arg);
int (*getsockopt)(struct atm_vcc *vcc,int level,int optname, int (*getsockopt)(struct atm_vcc *vcc,int level,int optname,
void *optval,int optlen); void __user *optval,int optlen);
int (*setsockopt)(struct atm_vcc *vcc,int level,int optname, int (*setsockopt)(struct atm_vcc *vcc,int level,int optname,
void *optval,int optlen); void __user *optval,int optlen);
int (*send)(struct atm_vcc *vcc,struct sk_buff *skb); int (*send)(struct atm_vcc *vcc,struct sk_buff *skb);
int (*send_oam)(struct atm_vcc *vcc,void *cell,int flags); int (*send_oam)(struct atm_vcc *vcc,void *cell,int flags);
void (*phy_put)(struct atm_dev *dev,unsigned char value, void (*phy_put)(struct atm_dev *dev,unsigned char value,
...@@ -368,7 +368,7 @@ struct atmdev_ops { /* only send is required */ ...@@ -368,7 +368,7 @@ struct atmdev_ops { /* only send is required */
struct atmphy_ops { struct atmphy_ops {
int (*start)(struct atm_dev *dev); int (*start)(struct atm_dev *dev);
int (*ioctl)(struct atm_dev *dev,unsigned int cmd,void *arg); int (*ioctl)(struct atm_dev *dev,unsigned int cmd,void __user *arg);
void (*interrupt)(struct atm_dev *dev); void (*interrupt)(struct atm_dev *dev);
int (*stop)(struct atm_dev *dev); int (*stop)(struct atm_dev *dev);
}; };
......
...@@ -114,7 +114,7 @@ int atm_del_addr(struct atm_dev *dev,struct sockaddr_atmsvc *addr) ...@@ -114,7 +114,7 @@ int atm_del_addr(struct atm_dev *dev,struct sockaddr_atmsvc *addr)
} }
int atm_get_addr(struct atm_dev *dev,struct sockaddr_atmsvc *u_buf,int size) int atm_get_addr(struct atm_dev *dev,struct sockaddr_atmsvc __user *buf,int size)
{ {
unsigned long flags; unsigned long flags;
struct atm_dev_addr *walk; struct atm_dev_addr *walk;
...@@ -134,7 +134,7 @@ int atm_get_addr(struct atm_dev *dev,struct sockaddr_atmsvc *u_buf,int size) ...@@ -134,7 +134,7 @@ int atm_get_addr(struct atm_dev *dev,struct sockaddr_atmsvc *u_buf,int size)
memcpy(tmp_bufp++, &walk->addr, sizeof(struct sockaddr_atmsvc)); memcpy(tmp_bufp++, &walk->addr, sizeof(struct sockaddr_atmsvc));
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
error = total > size ? -E2BIG : total; error = total > size ? -E2BIG : total;
if (copy_to_user(u_buf, tmp_buf, total < size ? total : size)) if (copy_to_user(buf, tmp_buf, total < size ? total : size))
error = -EFAULT; error = -EFAULT;
kfree(tmp_buf); kfree(tmp_buf);
return error; return error;
......
...@@ -13,6 +13,6 @@ ...@@ -13,6 +13,6 @@
void atm_reset_addr(struct atm_dev *dev); void atm_reset_addr(struct atm_dev *dev);
int atm_add_addr(struct atm_dev *dev,struct sockaddr_atmsvc *addr); int atm_add_addr(struct atm_dev *dev,struct sockaddr_atmsvc *addr);
int atm_del_addr(struct atm_dev *dev,struct sockaddr_atmsvc *addr); int atm_del_addr(struct atm_dev *dev,struct sockaddr_atmsvc *addr);
int atm_get_addr(struct atm_dev *dev,struct sockaddr_atmsvc *u_buf,int size); int atm_get_addr(struct atm_dev *dev,struct sockaddr_atmsvc __user *buf,int size);
#endif #endif
...@@ -342,12 +342,12 @@ static int br2684_mac_addr(struct net_device *dev, void *p) ...@@ -342,12 +342,12 @@ static int br2684_mac_addr(struct net_device *dev, void *p)
#ifdef CONFIG_ATM_BR2684_IPFILTER #ifdef CONFIG_ATM_BR2684_IPFILTER
/* this IOCTL is experimental. */ /* this IOCTL is experimental. */
static int br2684_setfilt(struct atm_vcc *atmvcc, unsigned long arg) static int br2684_setfilt(struct atm_vcc *atmvcc, void __user *arg)
{ {
struct br2684_vcc *brvcc; struct br2684_vcc *brvcc;
struct br2684_filter_set fs; struct br2684_filter_set fs;
if (copy_from_user(&fs, (void *) arg, sizeof fs)) if (copy_from_user(&fs, arg, sizeof fs))
return -EFAULT; return -EFAULT;
if (fs.ifspec.method != BR2684_FIND_BYNOTHING) { if (fs.ifspec.method != BR2684_FIND_BYNOTHING) {
/* /*
...@@ -494,7 +494,7 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb) ...@@ -494,7 +494,7 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)
netif_rx(skb); netif_rx(skb);
} }
static int br2684_regvcc(struct atm_vcc *atmvcc, unsigned long arg) static int br2684_regvcc(struct atm_vcc *atmvcc, void __user *arg)
{ {
/* assign a vcc to a dev /* assign a vcc to a dev
Note: we do not have explicit unassign, but look at _push() Note: we do not have explicit unassign, but look at _push()
...@@ -507,7 +507,7 @@ Note: we do not have explicit unassign, but look at _push() ...@@ -507,7 +507,7 @@ Note: we do not have explicit unassign, but look at _push()
struct net_device *net_dev; struct net_device *net_dev;
struct atm_backend_br2684 be; struct atm_backend_br2684 be;
if (copy_from_user(&be, (void *) arg, sizeof be)) if (copy_from_user(&be, arg, sizeof be))
return -EFAULT; return -EFAULT;
brvcc = kmalloc(sizeof(struct br2684_vcc), GFP_KERNEL); brvcc = kmalloc(sizeof(struct br2684_vcc), GFP_KERNEL);
if (!brvcc) if (!brvcc)
...@@ -593,7 +593,7 @@ static void br2684_setup(struct net_device *netdev) ...@@ -593,7 +593,7 @@ static void br2684_setup(struct net_device *netdev)
INIT_LIST_HEAD(&brdev->brvccs); INIT_LIST_HEAD(&brdev->brvccs);
} }
static int br2684_create(unsigned long arg) static int br2684_create(void __user *arg)
{ {
int err; int err;
struct net_device *netdev; struct net_device *netdev;
...@@ -602,7 +602,7 @@ static int br2684_create(unsigned long arg) ...@@ -602,7 +602,7 @@ static int br2684_create(unsigned long arg)
DPRINTK("br2684_create\n"); DPRINTK("br2684_create\n");
if (copy_from_user(&ni, (void *) arg, sizeof ni)) { if (copy_from_user(&ni, arg, sizeof ni)) {
return -EFAULT; return -EFAULT;
} }
if (ni.media != BR2684_MEDIA_ETHERNET || ni.mtu != 1500) { if (ni.media != BR2684_MEDIA_ETHERNET || ni.mtu != 1500) {
...@@ -642,13 +642,14 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd, ...@@ -642,13 +642,14 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
struct atm_vcc *atmvcc = ATM_SD(sock); struct atm_vcc *atmvcc = ATM_SD(sock);
void __user *argp = (void __user *)arg;
int err; int err;
switch(cmd) { switch(cmd) {
case ATM_SETBACKEND: case ATM_SETBACKEND:
case ATM_NEWBACKENDIF: { case ATM_NEWBACKENDIF: {
atm_backend_t b; atm_backend_t b;
err = get_user(b, (atm_backend_t *) arg); err = get_user(b, (atm_backend_t __user *) argp);
if (err) if (err)
return -EFAULT; return -EFAULT;
if (b != ATM_BACKEND_BR2684) if (b != ATM_BACKEND_BR2684)
...@@ -656,9 +657,9 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd, ...@@ -656,9 +657,9 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EPERM; return -EPERM;
if (cmd == ATM_SETBACKEND) if (cmd == ATM_SETBACKEND)
return br2684_regvcc(atmvcc, arg); return br2684_regvcc(atmvcc, argp);
else else
return br2684_create(arg); return br2684_create(argp);
} }
#ifdef CONFIG_ATM_BR2684_IPFILTER #ifdef CONFIG_ATM_BR2684_IPFILTER
case BR2684_SETFILT: case BR2684_SETFILT:
...@@ -666,7 +667,7 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd, ...@@ -666,7 +667,7 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EPERM; return -EPERM;
err = br2684_setfilt(atmvcc, arg); err = br2684_setfilt(atmvcc, argp);
return err; return err;
#endif /* CONFIG_ATM_BR2684_IPFILTER */ #endif /* CONFIG_ATM_BR2684_IPFILTER */
} }
......
...@@ -509,7 +509,7 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, ...@@ -509,7 +509,7 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
struct atm_vcc *vcc; struct atm_vcc *vcc;
struct sk_buff *skb; struct sk_buff *skb;
int eff,error; int eff,error;
const void *buff; const void __user *buff;
int size; int size;
lock_sock(sk); lock_sock(sk);
...@@ -676,7 +676,7 @@ static int check_qos(struct atm_qos *qos) ...@@ -676,7 +676,7 @@ static int check_qos(struct atm_qos *qos)
} }
int vcc_setsockopt(struct socket *sock, int level, int optname, int vcc_setsockopt(struct socket *sock, int level, int optname,
char *optval, int optlen) char __user *optval, int optlen)
{ {
struct atm_vcc *vcc; struct atm_vcc *vcc;
unsigned long value; unsigned long value;
...@@ -704,7 +704,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname, ...@@ -704,7 +704,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname,
return 0; return 0;
} }
case SO_SETCLP: case SO_SETCLP:
if (get_user(value,(unsigned long *) optval)) if (get_user(value,(unsigned long __user *)optval))
return -EFAULT; return -EFAULT;
if (value) vcc->atm_options |= ATM_ATMOPT_CLP; if (value) vcc->atm_options |= ATM_ATMOPT_CLP;
else vcc->atm_options &= ~ATM_ATMOPT_CLP; else vcc->atm_options &= ~ATM_ATMOPT_CLP;
...@@ -719,7 +719,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname, ...@@ -719,7 +719,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname,
int vcc_getsockopt(struct socket *sock, int level, int optname, int vcc_getsockopt(struct socket *sock, int level, int optname,
char *optval, int *optlen) char __user *optval, int __user *optlen)
{ {
struct atm_vcc *vcc; struct atm_vcc *vcc;
int len; int len;
...@@ -738,7 +738,7 @@ int vcc_getsockopt(struct socket *sock, int level, int optname, ...@@ -738,7 +738,7 @@ int vcc_getsockopt(struct socket *sock, int level, int optname,
-EFAULT : 0; -EFAULT : 0;
case SO_SETCLP: case SO_SETCLP:
return put_user(vcc->atm_options & ATM_ATMOPT_CLP ? 1 : return put_user(vcc->atm_options & ATM_ATMOPT_CLP ? 1 :
0,(unsigned long *) optval) ? -EFAULT : 0; 0,(unsigned long __user *)optval) ? -EFAULT : 0;
case SO_ATMPVC: case SO_ATMPVC:
{ {
struct sockaddr_atmpvc pvc; struct sockaddr_atmpvc pvc;
......
...@@ -19,10 +19,10 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, ...@@ -19,10 +19,10 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
size_t total_len); size_t total_len);
unsigned int vcc_poll(struct file *file, struct socket *sock, poll_table *wait); unsigned int vcc_poll(struct file *file, struct socket *sock, poll_table *wait);
int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
int vcc_setsockopt(struct socket *sock, int level, int optname, char *optval, int vcc_setsockopt(struct socket *sock, int level, int optname,
int optlen); char __user *optval, int optlen);
int vcc_getsockopt(struct socket *sock, int level, int optname, char *optval, int vcc_getsockopt(struct socket *sock, int level, int optname,
int *optlen); char __user *optval, int __user *optlen);
void atm_shutdown_dev(struct atm_dev *dev); void atm_shutdown_dev(struct atm_dev *dev);
......
...@@ -49,6 +49,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -49,6 +49,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
struct atm_vcc *vcc; struct atm_vcc *vcc;
int error; int error;
struct list_head * pos; struct list_head * pos;
void __user *argp = (void __user *)arg;
vcc = ATM_SD(sock); vcc = ATM_SD(sock);
switch (cmd) { switch (cmd) {
...@@ -60,7 +61,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -60,7 +61,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
} }
error = put_user(vcc->sk->sk_sndbuf - error = put_user(vcc->sk->sk_sndbuf -
atomic_read(&vcc->sk->sk_wmem_alloc), atomic_read(&vcc->sk->sk_wmem_alloc),
(int *) arg) ? -EFAULT : 0; (int __user *) argp) ? -EFAULT : 0;
goto done; goto done;
case SIOCINQ: case SIOCINQ:
{ {
...@@ -72,12 +73,11 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -72,12 +73,11 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
} }
skb = skb_peek(&vcc->sk->sk_receive_queue); skb = skb_peek(&vcc->sk->sk_receive_queue);
error = put_user(skb ? skb->len : 0, error = put_user(skb ? skb->len : 0,
(int *) arg) ? -EFAULT : 0; (int __user *)argp) ? -EFAULT : 0;
goto done; goto done;
} }
case SIOCGSTAMP: /* borrowed from IP */ case SIOCGSTAMP: /* borrowed from IP */
error = sock_get_timestamp(vcc->sk, error = sock_get_timestamp(vcc->sk, argp);
(struct timeval __user *) arg);
goto done; goto done;
case ATM_SETSC: case ATM_SETSC:
printk(KERN_WARNING "ATM_SETSC is obsolete\n"); printk(KERN_WARNING "ATM_SETSC is obsolete\n");
...@@ -131,7 +131,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -131,7 +131,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
if (error != -ENOIOCTLCMD) if (error != -ENOIOCTLCMD)
goto done; goto done;
error = atm_dev_ioctl(cmd, arg); error = atm_dev_ioctl(cmd, argp);
done: done:
return error; return error;
......
...@@ -774,7 +774,7 @@ lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -774,7 +774,7 @@ lec_pop(struct atm_vcc *vcc, struct sk_buff *skb)
} }
int int
lec_vcc_attach(struct atm_vcc *vcc, void *arg) lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
{ {
struct lec_vcc_priv *vpriv; struct lec_vcc_priv *vpriv;
int bytes_left; int bytes_left;
...@@ -1161,7 +1161,7 @@ static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1161,7 +1161,7 @@ static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
err = lec_mcast_attach(vcc, (int) arg); err = lec_mcast_attach(vcc, (int) arg);
break; break;
case ATMLEC_DATA: case ATMLEC_DATA:
err = lec_vcc_attach(vcc, (void *) arg); err = lec_vcc_attach(vcc, (void __user *) arg);
break; break;
} }
......
...@@ -148,7 +148,7 @@ struct lec_vcc_priv { ...@@ -148,7 +148,7 @@ struct lec_vcc_priv {
#define LEC_VCC_PRIV(vcc) ((struct lec_vcc_priv *)((vcc)->user_back)) #define LEC_VCC_PRIV(vcc) ((struct lec_vcc_priv *)((vcc)->user_back))
int lecd_attach(struct atm_vcc *vcc, int arg); int lecd_attach(struct atm_vcc *vcc, int arg);
int lec_vcc_attach(struct atm_vcc *vcc, void *arg); int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg);
int lec_mcast_attach(struct atm_vcc *vcc, int arg); int lec_mcast_attach(struct atm_vcc *vcc, int arg);
struct net_device *get_dev_lec(int itf); struct net_device *get_dev_lec(int itf);
int make_lec(struct atm_vcc *vcc); int make_lec(struct atm_vcc *vcc);
......
...@@ -565,7 +565,7 @@ static int mpc_send_packet(struct sk_buff *skb, struct net_device *dev) ...@@ -565,7 +565,7 @@ static int mpc_send_packet(struct sk_buff *skb, struct net_device *dev)
return retval; return retval;
} }
int atm_mpoa_vcc_attach(struct atm_vcc *vcc, long arg) int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg)
{ {
int bytes_left; int bytes_left;
struct mpoa_client *mpc; struct mpoa_client *mpc;
...@@ -574,7 +574,7 @@ int atm_mpoa_vcc_attach(struct atm_vcc *vcc, long arg) ...@@ -574,7 +574,7 @@ int atm_mpoa_vcc_attach(struct atm_vcc *vcc, long arg)
uint32_t ipaddr; uint32_t ipaddr;
unsigned char *ip; unsigned char *ip;
bytes_left = copy_from_user(&ioc_data, (void *)arg, sizeof(struct atmmpc_ioc)); bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmmpc_ioc));
if (bytes_left != 0) { if (bytes_left != 0) {
printk("mpoa: mpc_vcc_attach: Short read (missed %d bytes) from userland\n", bytes_left); printk("mpoa: mpc_vcc_attach: Short read (missed %d bytes) from userland\n", bytes_left);
return -EFAULT; return -EFAULT;
...@@ -1366,7 +1366,7 @@ static void clean_up(struct k_message *msg, struct mpoa_client *mpc, int action) ...@@ -1366,7 +1366,7 @@ static void clean_up(struct k_message *msg, struct mpoa_client *mpc, int action)
return; return;
} }
static void mpc_timer_refresh() static void mpc_timer_refresh(void)
{ {
mpc_timer.expires = jiffies + (MPC_P2 * HZ); mpc_timer.expires = jiffies + (MPC_P2 * HZ);
mpc_timer.data = mpc_timer.expires; mpc_timer.data = mpc_timer.expires;
...@@ -1418,7 +1418,7 @@ static int atm_mpoa_ioctl(struct socket *sock, unsigned int cmd, unsigned long a ...@@ -1418,7 +1418,7 @@ static int atm_mpoa_ioctl(struct socket *sock, unsigned int cmd, unsigned long a
sock->state = SS_CONNECTED; sock->state = SS_CONNECTED;
break; break;
case ATMMPC_DATA: case ATMMPC_DATA:
err = atm_mpoa_vcc_attach(vcc, arg); err = atm_mpoa_vcc_attach(vcc, (void __user *)arg);
break; break;
default: default:
break; break;
......
...@@ -13,7 +13,7 @@ int msg_to_mpoad(struct k_message *msg, struct mpoa_client *mpc); ...@@ -13,7 +13,7 @@ int msg_to_mpoad(struct k_message *msg, struct mpoa_client *mpc);
/* Functions for ioctl(ATMMPC_*) operations */ /* Functions for ioctl(ATMMPC_*) operations */
int atm_mpoa_mpoad_attach(struct atm_vcc *vcc, int arg); int atm_mpoa_mpoad_attach(struct atm_vcc *vcc, int arg);
int atm_mpoa_vcc_attach(struct atm_vcc *vcc, long arg); int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg);
struct mpoa_client { struct mpoa_client {
struct mpoa_client *next; struct mpoa_client *next;
......
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
extern struct mpoa_client *mpcs; extern struct mpoa_client *mpcs;
extern struct proc_dir_entry *atm_proc_root; /* from proc.c. */ extern struct proc_dir_entry *atm_proc_root; /* from proc.c. */
static ssize_t proc_mpc_read(struct file *file, char *buff, static ssize_t proc_mpc_read(struct file *file, char __user *buff,
size_t count, loff_t *pos); size_t count, loff_t *pos);
static ssize_t proc_mpc_write(struct file *file, const char *buff, static ssize_t proc_mpc_write(struct file *file, const char __user *buff,
size_t nbytes, loff_t *ppos); size_t nbytes, loff_t *ppos);
static int parse_qos(const char *buff, int len); static int parse_qos(const char *buff, int len);
...@@ -99,7 +99,7 @@ static const char *egress_state_string(int state){ ...@@ -99,7 +99,7 @@ static const char *egress_state_string(int state){
/* /*
* READING function - called when the /proc/atm/mpoa file is read from. * READING function - called when the /proc/atm/mpoa file is read from.
*/ */
static ssize_t proc_mpc_read(struct file *file, char *buff, static ssize_t proc_mpc_read(struct file *file, char __user *buff,
size_t count, loff_t *pos){ size_t count, loff_t *pos){
unsigned long page = 0; unsigned long page = 0;
unsigned char *temp; unsigned char *temp;
...@@ -165,12 +165,12 @@ static ssize_t proc_mpc_read(struct file *file, char *buff, ...@@ -165,12 +165,12 @@ static ssize_t proc_mpc_read(struct file *file, char *buff,
return length; return length;
} }
static ssize_t proc_mpc_write(struct file *file, const char *buff, static ssize_t proc_mpc_write(struct file *file, const char __user *buff,
size_t nbytes, loff_t *ppos) size_t nbytes, loff_t *ppos)
{ {
int incoming, error, retval; int incoming, error, retval;
char *page, c; char *page, c;
const char *tmp; const char __user *tmp;
if (nbytes == 0) return 0; if (nbytes == 0) return 0;
if (nbytes >= PAGE_SIZE) nbytes = PAGE_SIZE-1; if (nbytes >= PAGE_SIZE) nbytes = PAGE_SIZE-1;
......
...@@ -257,10 +257,10 @@ static int pppoatm_devppp_ioctl(struct ppp_channel *chan, unsigned int cmd, ...@@ -257,10 +257,10 @@ static int pppoatm_devppp_ioctl(struct ppp_channel *chan, unsigned int cmd,
{ {
switch (cmd) { switch (cmd) {
case PPPIOCGFLAGS: case PPPIOCGFLAGS:
return put_user(chan_to_pvcc(chan)->flags, (int *) arg) return put_user(chan_to_pvcc(chan)->flags, (int __user *) arg)
? -EFAULT : 0; ? -EFAULT : 0;
case PPPIOCSFLAGS: case PPPIOCSFLAGS:
return get_user(chan_to_pvcc(chan)->flags, (int *) arg) return get_user(chan_to_pvcc(chan)->flags, (int __user *) arg)
? -EFAULT : 0; ? -EFAULT : 0;
} }
return -ENOTTY; return -ENOTTY;
...@@ -271,7 +271,7 @@ static /*const*/ struct ppp_channel_ops pppoatm_ops = { ...@@ -271,7 +271,7 @@ static /*const*/ struct ppp_channel_ops pppoatm_ops = {
.ioctl = pppoatm_devppp_ioctl, .ioctl = pppoatm_devppp_ioctl,
}; };
static int pppoatm_assign_vcc(struct atm_vcc *atmvcc, unsigned long arg) static int pppoatm_assign_vcc(struct atm_vcc *atmvcc, void __user *arg)
{ {
struct atm_backend_ppp be; struct atm_backend_ppp be;
struct pppoatm_vcc *pvcc; struct pppoatm_vcc *pvcc;
...@@ -281,7 +281,7 @@ static int pppoatm_assign_vcc(struct atm_vcc *atmvcc, unsigned long arg) ...@@ -281,7 +281,7 @@ static int pppoatm_assign_vcc(struct atm_vcc *atmvcc, unsigned long arg)
* prototypical one used to initialize them * prototypical one used to initialize them
*/ */
static const DECLARE_TASKLET(tasklet_proto, pppoatm_wakeup_sender, 0); static const DECLARE_TASKLET(tasklet_proto, pppoatm_wakeup_sender, 0);
if (copy_from_user(&be, (void *) arg, sizeof be)) if (copy_from_user(&be, arg, sizeof be))
return -EFAULT; return -EFAULT;
if (be.encaps != PPPOATM_ENCAPS_AUTODETECT && if (be.encaps != PPPOATM_ENCAPS_AUTODETECT &&
be.encaps != PPPOATM_ENCAPS_VC && be.encaps != PPPOATM_ENCAPS_LLC) be.encaps != PPPOATM_ENCAPS_VC && be.encaps != PPPOATM_ENCAPS_LLC)
...@@ -319,26 +319,27 @@ static int pppoatm_ioctl(struct socket *sock, unsigned int cmd, ...@@ -319,26 +319,27 @@ static int pppoatm_ioctl(struct socket *sock, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
struct atm_vcc *atmvcc = ATM_SD(sock); struct atm_vcc *atmvcc = ATM_SD(sock);
void __user *argp = (void __user *)arg;
if (cmd != ATM_SETBACKEND && atmvcc->push != pppoatm_push) if (cmd != ATM_SETBACKEND && atmvcc->push != pppoatm_push)
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
switch (cmd) { switch (cmd) {
case ATM_SETBACKEND: { case ATM_SETBACKEND: {
atm_backend_t b; atm_backend_t b;
if (get_user(b, (atm_backend_t *) arg)) if (get_user(b, (atm_backend_t __user *) argp))
return -EFAULT; return -EFAULT;
if (b != ATM_BACKEND_PPP) if (b != ATM_BACKEND_PPP)
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EPERM; return -EPERM;
return pppoatm_assign_vcc(atmvcc, arg); return pppoatm_assign_vcc(atmvcc, argp);
} }
case PPPIOCGCHAN: case PPPIOCGCHAN:
return put_user(ppp_channel_index(&atmvcc_to_pvcc(atmvcc)-> return put_user(ppp_channel_index(&atmvcc_to_pvcc(atmvcc)->
chan), (int *) arg) ? -EFAULT : 0; chan), (int __user *) argp) ? -EFAULT : 0;
case PPPIOCGUNIT: case PPPIOCGUNIT:
return put_user(ppp_unit_number(&atmvcc_to_pvcc(atmvcc)-> return put_user(ppp_unit_number(&atmvcc_to_pvcc(atmvcc)->
chan), (int *) arg) ? -EFAULT : 0; chan), (int __user *) argp) ? -EFAULT : 0;
} }
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "common.h" /* atm_proc_init prototype */ #include "common.h" /* atm_proc_init prototype */
#include "signaling.h" /* to get sigd - ugly too */ #include "signaling.h" /* to get sigd - ugly too */
static ssize_t proc_dev_atm_read(struct file *file,char *buf,size_t count, static ssize_t proc_dev_atm_read(struct file *file,char __user *buf,size_t count,
loff_t *pos); loff_t *pos);
static struct file_operations proc_atm_dev_ops = { static struct file_operations proc_atm_dev_ops = {
...@@ -384,8 +384,8 @@ static struct file_operations svc_seq_fops = { ...@@ -384,8 +384,8 @@ static struct file_operations svc_seq_fops = {
.release = vcc_seq_release, .release = vcc_seq_release,
}; };
static ssize_t proc_dev_atm_read(struct file *file,char *buf,size_t count, static ssize_t proc_dev_atm_read(struct file *file, char __user *buf,
loff_t *pos) size_t count, loff_t *pos)
{ {
struct atm_dev *dev; struct atm_dev *dev;
unsigned long page; unsigned long page;
......
...@@ -180,7 +180,7 @@ static void subtract_aal_stats(struct k_atm_aal_stats *from, ...@@ -180,7 +180,7 @@ static void subtract_aal_stats(struct k_atm_aal_stats *from,
} }
static int fetch_stats(struct atm_dev *dev, struct atm_dev_stats *arg, int zero) static int fetch_stats(struct atm_dev *dev, struct atm_dev_stats __user *arg, int zero)
{ {
struct atm_dev_stats tmp; struct atm_dev_stats tmp;
int error = 0; int error = 0;
...@@ -199,19 +199,20 @@ static int fetch_stats(struct atm_dev *dev, struct atm_dev_stats *arg, int zero) ...@@ -199,19 +199,20 @@ static int fetch_stats(struct atm_dev *dev, struct atm_dev_stats *arg, int zero)
} }
int atm_dev_ioctl(unsigned int cmd, unsigned long arg) int atm_dev_ioctl(unsigned int cmd, void __user *arg)
{ {
void *buf; void __user *buf;
int error, len, number, size = 0; int error, len, number, size = 0;
struct atm_dev *dev; struct atm_dev *dev;
struct list_head *p; struct list_head *p;
int *tmp_buf, *tmp_p; int *tmp_buf, *tmp_p;
struct atm_iobuf __user *iobuf = arg;
struct atmif_sioc __user *sioc = arg;
switch (cmd) { switch (cmd) {
case ATM_GETNAMES: case ATM_GETNAMES:
if (get_user(buf, &((struct atm_iobuf *) arg)->buffer)) if (get_user(buf, &iobuf->buffer))
return -EFAULT; return -EFAULT;
if (get_user(len, &((struct atm_iobuf *) arg)->length)) if (get_user(len, &iobuf->length))
return -EFAULT; return -EFAULT;
spin_lock(&atm_dev_lock); spin_lock(&atm_dev_lock);
list_for_each(p, &atm_devs) list_for_each(p, &atm_devs)
...@@ -232,7 +233,7 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg) ...@@ -232,7 +233,7 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
} }
spin_unlock(&atm_dev_lock); spin_unlock(&atm_dev_lock);
error = ((copy_to_user(buf, tmp_buf, size)) || error = ((copy_to_user(buf, tmp_buf, size)) ||
put_user(size, &((struct atm_iobuf *) arg)->length)) put_user(size, &iobuf->length))
? -EFAULT : 0; ? -EFAULT : 0;
kfree(tmp_buf); kfree(tmp_buf);
return error; return error;
...@@ -240,11 +241,11 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg) ...@@ -240,11 +241,11 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
break; break;
} }
if (get_user(buf, &((struct atmif_sioc *) arg)->arg)) if (get_user(buf, &sioc->arg))
return -EFAULT; return -EFAULT;
if (get_user(len, &((struct atmif_sioc *) arg)->length)) if (get_user(len, &sioc->length))
return -EFAULT; return -EFAULT;
if (get_user(number, &((struct atmif_sioc *) arg)->number)) if (get_user(number, &sioc->number))
return -EFAULT; return -EFAULT;
if (!(dev = atm_dev_lookup(number))) if (!(dev = atm_dev_lookup(number)))
...@@ -351,7 +352,7 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg) ...@@ -351,7 +352,7 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
size = error; size = error;
/* may return 0, but later on size == 0 means "don't /* may return 0, but later on size == 0 means "don't
write the length" */ write the length" */
error = put_user(size, &((struct atmif_sioc *) arg)->length) error = put_user(size, &sioc->length)
? -EFAULT : 0; ? -EFAULT : 0;
goto done; goto done;
case ATM_SETLOOP: case ATM_SETLOOP:
...@@ -385,7 +386,7 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg) ...@@ -385,7 +386,7 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
} }
if (size) if (size)
error = put_user(size, &((struct atmif_sioc *) arg)->length) error = put_user(size, &sioc->length)
? -EFAULT : 0; ? -EFAULT : 0;
else else
error = 0; error = 0;
......
...@@ -14,7 +14,7 @@ extern struct list_head atm_devs; ...@@ -14,7 +14,7 @@ extern struct list_head atm_devs;
extern spinlock_t atm_dev_lock; extern spinlock_t atm_dev_lock;
int atm_dev_ioctl(unsigned int cmd, unsigned long arg); int atm_dev_ioctl(unsigned int cmd, void __user *arg);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
......
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