Commit 1eb83e09 authored by Paul Mackerras's avatar Paul Mackerras Committed by Linus Torvalds

[PATCH] Fix check warnings in PPP code

This patch removes the warnings that the check program came up with in
the PPP code: ppp_async.c, ppp_deflate.c and ppp_generic.c.  This
involved adding __user and converting K&R-style function definitions
to ANSI-style.  I also took the time to add some extra comments to
ppp_deflate.c explaining in more detail what each function does and
what its arguments are.
parent 2a1775fd
...@@ -427,12 +427,12 @@ ppp_async_ioctl(struct ppp_channel *chan, unsigned int cmd, unsigned long arg) ...@@ -427,12 +427,12 @@ ppp_async_ioctl(struct ppp_channel *chan, unsigned int cmd, unsigned long arg)
break; break;
case PPPIOCGXASYNCMAP: case PPPIOCGXASYNCMAP:
if (copy_to_user((void *) arg, ap->xaccm, sizeof(ap->xaccm))) if (copy_to_user((void __user *) arg, ap->xaccm, sizeof(ap->xaccm)))
break; break;
err = 0; err = 0;
break; break;
case PPPIOCSXASYNCMAP: case PPPIOCSXASYNCMAP:
if (copy_from_user(accm, (void *) arg, sizeof(accm))) if (copy_from_user(accm, (void __user *) arg, sizeof(accm)))
break; break;
accm[2] &= ~0x40000000U; /* can't escape 0x5e */ accm[2] &= ~0x40000000U; /* can't escape 0x5e */
accm[3] |= 0x60000000U; /* must escape 0x7d, 0x7e */ accm[3] |= 0x60000000U; /* must escape 0x7d, 0x7e */
......
This diff is collapsed.
...@@ -387,7 +387,7 @@ static int ppp_release(struct inode *inode, struct file *file) ...@@ -387,7 +387,7 @@ static int ppp_release(struct inode *inode, struct file *file)
return 0; return 0;
} }
static ssize_t ppp_read(struct file *file, char *buf, static ssize_t ppp_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct ppp_file *pf = file->private_data; struct ppp_file *pf = file->private_data;
...@@ -436,7 +436,7 @@ static ssize_t ppp_read(struct file *file, char *buf, ...@@ -436,7 +436,7 @@ static ssize_t ppp_read(struct file *file, char *buf,
return ret; return ret;
} }
static ssize_t ppp_write(struct file *file, const char *buf, static ssize_t ppp_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct ppp_file *pf = file->private_data; struct ppp_file *pf = file->private_data;
...@@ -617,7 +617,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file, ...@@ -617,7 +617,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file,
case PPPIOCGIDLE: case PPPIOCGIDLE:
idle.xmit_idle = (jiffies - ppp->last_xmit) / HZ; idle.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
idle.recv_idle = (jiffies - ppp->last_recv) / HZ; idle.recv_idle = (jiffies - ppp->last_recv) / HZ;
if (copy_to_user((void *) arg, &idle, sizeof(idle))) if (copy_to_user((void __user *) arg, &idle, sizeof(idle)))
break; break;
err = 0; err = 0;
break; break;
...@@ -646,7 +646,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file, ...@@ -646,7 +646,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file,
case PPPIOCGNPMODE: case PPPIOCGNPMODE:
case PPPIOCSNPMODE: case PPPIOCSNPMODE:
if (copy_from_user(&npi, (void *) arg, sizeof(npi))) if (copy_from_user(&npi, (void __user *) arg, sizeof(npi)))
break; break;
err = proto_to_npindex(npi.protocol); err = proto_to_npindex(npi.protocol);
if (err < 0) if (err < 0)
...@@ -655,7 +655,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file, ...@@ -655,7 +655,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file,
if (cmd == PPPIOCGNPMODE) { if (cmd == PPPIOCGNPMODE) {
err = -EFAULT; err = -EFAULT;
npi.mode = ppp->npmode[i]; npi.mode = ppp->npmode[i];
if (copy_to_user((void *) arg, &npi, sizeof(npi))) if (copy_to_user((void __user *) arg, &npi, sizeof(npi)))
break; break;
} else { } else {
ppp->npmode[i] = npi.mode; ppp->npmode[i] = npi.mode;
...@@ -673,16 +673,15 @@ static int ppp_ioctl(struct inode *inode, struct file *file, ...@@ -673,16 +673,15 @@ static int ppp_ioctl(struct inode *inode, struct file *file,
struct sock_filter *code = NULL; struct sock_filter *code = NULL;
int len; int len;
if (copy_from_user(&uprog, (void *) arg, sizeof(uprog))) if (copy_from_user(&uprog, (void __user *) arg, sizeof(uprog)))
break; break;
if (uprog.len > 0 && uprog.len < 65536) {
err = -ENOMEM; err = -ENOMEM;
len = uprog.len * sizeof(struct sock_filter); len = uprog.len * sizeof(struct sock_filter);
code = kmalloc(len, GFP_KERNEL); code = kmalloc(len, GFP_KERNEL);
if (code == 0) if (code == 0)
break; break;
err = -EFAULT; err = -EFAULT;
if (copy_from_user(code, uprog.filter, len)) { if (copy_from_user(code, (void __user *) uprog.filter, len)) {
kfree(code); kfree(code);
break; break;
} }
...@@ -691,7 +690,6 @@ static int ppp_ioctl(struct inode *inode, struct file *file, ...@@ -691,7 +690,6 @@ static int ppp_ioctl(struct inode *inode, struct file *file,
kfree(code); kfree(code);
break; break;
} }
}
filtp = (cmd == PPPIOCSPASS)? &ppp->pass_filter: &ppp->active_filter; filtp = (cmd == PPPIOCSPASS)? &ppp->pass_filter: &ppp->active_filter;
ppp_lock(ppp); ppp_lock(ppp);
if (filtp->filter) if (filtp->filter)
...@@ -879,7 +877,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -879,7 +877,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{ {
struct ppp *ppp = dev->priv; struct ppp *ppp = dev->priv;
int err = -EFAULT; int err = -EFAULT;
void *addr = (void *) ifr->ifr_ifru.ifru_data; void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
struct ppp_stats stats; struct ppp_stats stats;
struct ppp_comp_stats cstats; struct ppp_comp_stats cstats;
char *vers; char *vers;
...@@ -1952,9 +1950,9 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg) ...@@ -1952,9 +1950,9 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg)
unsigned char ccp_option[CCP_MAX_OPTION_LENGTH]; unsigned char ccp_option[CCP_MAX_OPTION_LENGTH];
err = -EFAULT; err = -EFAULT;
if (copy_from_user(&data, (void *) arg, sizeof(data)) if (copy_from_user(&data, (void __user *) arg, sizeof(data))
|| (data.length <= CCP_MAX_OPTION_LENGTH || (data.length <= CCP_MAX_OPTION_LENGTH
&& copy_from_user(ccp_option, data.ptr, data.length))) && copy_from_user(ccp_option, (void __user *) data.ptr, data.length)))
goto out; goto out;
err = -EINVAL; err = -EINVAL;
if (data.length > CCP_MAX_OPTION_LENGTH if (data.length > CCP_MAX_OPTION_LENGTH
......
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