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)
struct atmif_sioc {
int number;
int length;
void *arg;
void __user *arg;
};
typedef unsigned short atm_backend_t;
......
......@@ -351,11 +351,11 @@ struct atmdev_ops { /* only send is required */
void (*dev_close)(struct atm_dev *dev);
int (*open)(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,
void *optval,int optlen);
void __user *optval,int optlen);
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_oam)(struct atm_vcc *vcc,void *cell,int flags);
void (*phy_put)(struct atm_dev *dev,unsigned char value,
......@@ -368,7 +368,7 @@ struct atmdev_ops { /* only send is required */
struct atmphy_ops {
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);
int (*stop)(struct atm_dev *dev);
};
......
......@@ -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;
struct atm_dev_addr *walk;
......@@ -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));
spin_unlock_irqrestore(&dev->lock, flags);
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;
kfree(tmp_buf);
return error;
......
......@@ -13,6 +13,6 @@
void atm_reset_addr(struct atm_dev *dev);
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_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
......@@ -342,12 +342,12 @@ static int br2684_mac_addr(struct net_device *dev, void *p)
#ifdef CONFIG_ATM_BR2684_IPFILTER
/* 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_filter_set fs;
if (copy_from_user(&fs, (void *) arg, sizeof fs))
if (copy_from_user(&fs, arg, sizeof fs))
return -EFAULT;
if (fs.ifspec.method != BR2684_FIND_BYNOTHING) {
/*
......@@ -494,7 +494,7 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *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
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 atm_backend_br2684 be;
if (copy_from_user(&be, (void *) arg, sizeof be))
if (copy_from_user(&be, arg, sizeof be))
return -EFAULT;
brvcc = kmalloc(sizeof(struct br2684_vcc), GFP_KERNEL);
if (!brvcc)
......@@ -593,7 +593,7 @@ static void br2684_setup(struct net_device *netdev)
INIT_LIST_HEAD(&brdev->brvccs);
}
static int br2684_create(unsigned long arg)
static int br2684_create(void __user *arg)
{
int err;
struct net_device *netdev;
......@@ -602,7 +602,7 @@ static int br2684_create(unsigned long arg)
DPRINTK("br2684_create\n");
if (copy_from_user(&ni, (void *) arg, sizeof ni)) {
if (copy_from_user(&ni, arg, sizeof ni)) {
return -EFAULT;
}
if (ni.media != BR2684_MEDIA_ETHERNET || ni.mtu != 1500) {
......@@ -642,13 +642,14 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,
unsigned long arg)
{
struct atm_vcc *atmvcc = ATM_SD(sock);
void __user *argp = (void __user *)arg;
int err;
switch(cmd) {
case ATM_SETBACKEND:
case ATM_NEWBACKENDIF: {
atm_backend_t b;
err = get_user(b, (atm_backend_t *) arg);
err = get_user(b, (atm_backend_t __user *) argp);
if (err)
return -EFAULT;
if (b != ATM_BACKEND_BR2684)
......@@ -656,9 +657,9 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,
if (!capable(CAP_NET_ADMIN))
return -EPERM;
if (cmd == ATM_SETBACKEND)
return br2684_regvcc(atmvcc, arg);
return br2684_regvcc(atmvcc, argp);
else
return br2684_create(arg);
return br2684_create(argp);
}
#ifdef CONFIG_ATM_BR2684_IPFILTER
case BR2684_SETFILT:
......@@ -666,7 +667,7 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,
return -ENOIOCTLCMD;
if (!capable(CAP_NET_ADMIN))
return -EPERM;
err = br2684_setfilt(atmvcc, arg);
err = br2684_setfilt(atmvcc, argp);
return err;
#endif /* CONFIG_ATM_BR2684_IPFILTER */
}
......
......@@ -509,7 +509,7 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
struct atm_vcc *vcc;
struct sk_buff *skb;
int eff,error;
const void *buff;
const void __user *buff;
int size;
lock_sock(sk);
......@@ -676,7 +676,7 @@ static int check_qos(struct atm_qos *qos)
}
int vcc_setsockopt(struct socket *sock, int level, int optname,
char *optval, int optlen)
char __user *optval, int optlen)
{
struct atm_vcc *vcc;
unsigned long value;
......@@ -704,7 +704,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname,
return 0;
}
case SO_SETCLP:
if (get_user(value,(unsigned long *) optval))
if (get_user(value,(unsigned long __user *)optval))
return -EFAULT;
if (value) 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,
int vcc_getsockopt(struct socket *sock, int level, int optname,
char *optval, int *optlen)
char __user *optval, int __user *optlen)
{
struct atm_vcc *vcc;
int len;
......@@ -738,7 +738,7 @@ int vcc_getsockopt(struct socket *sock, int level, int optname,
-EFAULT : 0;
case SO_SETCLP:
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:
{
struct sockaddr_atmpvc pvc;
......
......@@ -19,10 +19,10 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
size_t total_len);
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_setsockopt(struct socket *sock, int level, int optname, char *optval,
int optlen);
int vcc_getsockopt(struct socket *sock, int level, int optname, char *optval,
int *optlen);
int vcc_setsockopt(struct socket *sock, int level, int optname,
char __user *optval, int optlen);
int vcc_getsockopt(struct socket *sock, int level, int optname,
char __user *optval, int __user *optlen);
void atm_shutdown_dev(struct atm_dev *dev);
......
......@@ -49,6 +49,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
struct atm_vcc *vcc;
int error;
struct list_head * pos;
void __user *argp = (void __user *)arg;
vcc = ATM_SD(sock);
switch (cmd) {
......@@ -60,7 +61,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
}
error = put_user(vcc->sk->sk_sndbuf -
atomic_read(&vcc->sk->sk_wmem_alloc),
(int *) arg) ? -EFAULT : 0;
(int __user *) argp) ? -EFAULT : 0;
goto done;
case SIOCINQ:
{
......@@ -72,12 +73,11 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
}
skb = skb_peek(&vcc->sk->sk_receive_queue);
error = put_user(skb ? skb->len : 0,
(int *) arg) ? -EFAULT : 0;
(int __user *)argp) ? -EFAULT : 0;
goto done;
}
case SIOCGSTAMP: /* borrowed from IP */
error = sock_get_timestamp(vcc->sk,
(struct timeval __user *) arg);
error = sock_get_timestamp(vcc->sk, argp);
goto done;
case ATM_SETSC:
printk(KERN_WARNING "ATM_SETSC is obsolete\n");
......@@ -131,7 +131,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
if (error != -ENOIOCTLCMD)
goto done;
error = atm_dev_ioctl(cmd, arg);
error = atm_dev_ioctl(cmd, argp);
done:
return error;
......
......@@ -774,7 +774,7 @@ lec_pop(struct atm_vcc *vcc, struct sk_buff *skb)
}
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;
int bytes_left;
......@@ -1161,7 +1161,7 @@ static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
err = lec_mcast_attach(vcc, (int) arg);
break;
case ATMLEC_DATA:
err = lec_vcc_attach(vcc, (void *) arg);
err = lec_vcc_attach(vcc, (void __user *) arg);
break;
}
......
......@@ -148,7 +148,7 @@ struct lec_vcc_priv {
#define LEC_VCC_PRIV(vcc) ((struct lec_vcc_priv *)((vcc)->user_back))
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);
struct net_device *get_dev_lec(int itf);
int make_lec(struct atm_vcc *vcc);
......
......@@ -565,7 +565,7 @@ static int mpc_send_packet(struct sk_buff *skb, struct net_device *dev)
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;
struct mpoa_client *mpc;
......@@ -574,7 +574,7 @@ int atm_mpoa_vcc_attach(struct atm_vcc *vcc, long arg)
uint32_t ipaddr;
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) {
printk("mpoa: mpc_vcc_attach: Short read (missed %d bytes) from userland\n", bytes_left);
return -EFAULT;
......@@ -1366,7 +1366,7 @@ static void clean_up(struct k_message *msg, struct mpoa_client *mpc, int action)
return;
}
static void mpc_timer_refresh()
static void mpc_timer_refresh(void)
{
mpc_timer.expires = jiffies + (MPC_P2 * HZ);
mpc_timer.data = mpc_timer.expires;
......@@ -1418,7 +1418,7 @@ static int atm_mpoa_ioctl(struct socket *sock, unsigned int cmd, unsigned long a
sock->state = SS_CONNECTED;
break;
case ATMMPC_DATA:
err = atm_mpoa_vcc_attach(vcc, arg);
err = atm_mpoa_vcc_attach(vcc, (void __user *)arg);
break;
default:
break;
......
......@@ -13,7 +13,7 @@ int msg_to_mpoad(struct k_message *msg, struct mpoa_client *mpc);
/* Functions for ioctl(ATMMPC_*) operations */
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 *next;
......
......@@ -30,10 +30,10 @@
extern struct mpoa_client *mpcs;
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);
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);
static int parse_qos(const char *buff, int len);
......@@ -99,7 +99,7 @@ static const char *egress_state_string(int state){
/*
* 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){
unsigned long page = 0;
unsigned char *temp;
......@@ -165,12 +165,12 @@ static ssize_t proc_mpc_read(struct file *file, char *buff,
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)
{
int incoming, error, retval;
char *page, c;
const char *tmp;
const char __user *tmp;
if (nbytes == 0) return 0;
if (nbytes >= PAGE_SIZE) nbytes = PAGE_SIZE-1;
......
......@@ -257,10 +257,10 @@ static int pppoatm_devppp_ioctl(struct ppp_channel *chan, unsigned int cmd,
{
switch (cmd) {
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;
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;
}
return -ENOTTY;
......@@ -271,7 +271,7 @@ static /*const*/ struct ppp_channel_ops pppoatm_ops = {
.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 pppoatm_vcc *pvcc;
......@@ -281,7 +281,7 @@ static int pppoatm_assign_vcc(struct atm_vcc *atmvcc, unsigned long arg)
* prototypical one used to initialize them
*/
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;
if (be.encaps != PPPOATM_ENCAPS_AUTODETECT &&
be.encaps != PPPOATM_ENCAPS_VC && be.encaps != PPPOATM_ENCAPS_LLC)
......@@ -319,26 +319,27 @@ static int pppoatm_ioctl(struct socket *sock, unsigned int cmd,
unsigned long arg)
{
struct atm_vcc *atmvcc = ATM_SD(sock);
void __user *argp = (void __user *)arg;
if (cmd != ATM_SETBACKEND && atmvcc->push != pppoatm_push)
return -ENOIOCTLCMD;
switch (cmd) {
case ATM_SETBACKEND: {
atm_backend_t b;
if (get_user(b, (atm_backend_t *) arg))
if (get_user(b, (atm_backend_t __user *) argp))
return -EFAULT;
if (b != ATM_BACKEND_PPP)
return -ENOIOCTLCMD;
if (!capable(CAP_NET_ADMIN))
return -EPERM;
return pppoatm_assign_vcc(atmvcc, arg);
return pppoatm_assign_vcc(atmvcc, argp);
}
case PPPIOCGCHAN:
return put_user(ppp_channel_index(&atmvcc_to_pvcc(atmvcc)->
chan), (int *) arg) ? -EFAULT : 0;
chan), (int __user *) argp) ? -EFAULT : 0;
case PPPIOCGUNIT:
return put_user(ppp_unit_number(&atmvcc_to_pvcc(atmvcc)->
chan), (int *) arg) ? -EFAULT : 0;
chan), (int __user *) argp) ? -EFAULT : 0;
}
return -ENOIOCTLCMD;
}
......
......@@ -31,7 +31,7 @@
#include "common.h" /* atm_proc_init prototype */
#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);
static struct file_operations proc_atm_dev_ops = {
......@@ -384,8 +384,8 @@ static struct file_operations svc_seq_fops = {
.release = vcc_seq_release,
};
static ssize_t proc_dev_atm_read(struct file *file,char *buf,size_t count,
loff_t *pos)
static ssize_t proc_dev_atm_read(struct file *file, char __user *buf,
size_t count, loff_t *pos)
{
struct atm_dev *dev;
unsigned long page;
......
......@@ -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;
int error = 0;
......@@ -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;
struct atm_dev *dev;
struct list_head *p;
int *tmp_buf, *tmp_p;
struct atm_iobuf __user *iobuf = arg;
struct atmif_sioc __user *sioc = arg;
switch (cmd) {
case ATM_GETNAMES:
if (get_user(buf, &((struct atm_iobuf *) arg)->buffer))
if (get_user(buf, &iobuf->buffer))
return -EFAULT;
if (get_user(len, &((struct atm_iobuf *) arg)->length))
if (get_user(len, &iobuf->length))
return -EFAULT;
spin_lock(&atm_dev_lock);
list_for_each(p, &atm_devs)
......@@ -232,7 +233,7 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
}
spin_unlock(&atm_dev_lock);
error = ((copy_to_user(buf, tmp_buf, size)) ||
put_user(size, &((struct atm_iobuf *) arg)->length))
put_user(size, &iobuf->length))
? -EFAULT : 0;
kfree(tmp_buf);
return error;
......@@ -240,11 +241,11 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
break;
}
if (get_user(buf, &((struct atmif_sioc *) arg)->arg))
if (get_user(buf, &sioc->arg))
return -EFAULT;
if (get_user(len, &((struct atmif_sioc *) arg)->length))
if (get_user(len, &sioc->length))
return -EFAULT;
if (get_user(number, &((struct atmif_sioc *) arg)->number))
if (get_user(number, &sioc->number))
return -EFAULT;
if (!(dev = atm_dev_lookup(number)))
......@@ -351,7 +352,7 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
size = error;
/* may return 0, but later on size == 0 means "don't
write the length" */
error = put_user(size, &((struct atmif_sioc *) arg)->length)
error = put_user(size, &sioc->length)
? -EFAULT : 0;
goto done;
case ATM_SETLOOP:
......@@ -385,7 +386,7 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
}
if (size)
error = put_user(size, &((struct atmif_sioc *) arg)->length)
error = put_user(size, &sioc->length)
? -EFAULT : 0;
else
error = 0;
......
......@@ -14,7 +14,7 @@ extern struct list_head atm_devs;
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
......
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