Commit f3ff8a4d authored by Alan Cox's avatar Alan Cox Committed by David S. Miller

ppp: push BKL down into the driver

I've pushed it down as far as I dare at this point. Someone familiar with
the internal PPP semantics can probably push it further. Another step to
eliminating the old BKL ioctl usage.
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 43154d08
...@@ -361,7 +361,7 @@ static int ppp_open(struct inode *inode, struct file *file) ...@@ -361,7 +361,7 @@ static int ppp_open(struct inode *inode, struct file *file)
return 0; return 0;
} }
static int ppp_release(struct inode *inode, struct file *file) static int ppp_release(struct inode *unused, struct file *file)
{ {
struct ppp_file *pf = file->private_data; struct ppp_file *pf = file->private_data;
struct ppp *ppp; struct ppp *ppp;
...@@ -545,8 +545,7 @@ static int get_filter(void __user *arg, struct sock_filter **p) ...@@ -545,8 +545,7 @@ static int get_filter(void __user *arg, struct sock_filter **p)
} }
#endif /* CONFIG_PPP_FILTER */ #endif /* CONFIG_PPP_FILTER */
static int ppp_ioctl(struct inode *inode, struct file *file, static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
unsigned int cmd, unsigned long arg)
{ {
struct ppp_file *pf = file->private_data; struct ppp_file *pf = file->private_data;
struct ppp *ppp; struct ppp *ppp;
...@@ -574,24 +573,29 @@ static int ppp_ioctl(struct inode *inode, struct file *file, ...@@ -574,24 +573,29 @@ static int ppp_ioctl(struct inode *inode, struct file *file,
* this fd and reopening /dev/ppp. * this fd and reopening /dev/ppp.
*/ */
err = -EINVAL; err = -EINVAL;
lock_kernel();
if (pf->kind == INTERFACE) { if (pf->kind == INTERFACE) {
ppp = PF_TO_PPP(pf); ppp = PF_TO_PPP(pf);
if (file == ppp->owner) if (file == ppp->owner)
ppp_shutdown_interface(ppp); ppp_shutdown_interface(ppp);
} }
if (atomic_read(&file->f_count) <= 2) { if (atomic_read(&file->f_count) <= 2) {
ppp_release(inode, file); ppp_release(NULL, file);
err = 0; err = 0;
} else } else
printk(KERN_DEBUG "PPPIOCDETACH file->f_count=%d\n", printk(KERN_DEBUG "PPPIOCDETACH file->f_count=%d\n",
atomic_read(&file->f_count)); atomic_read(&file->f_count));
unlock_kernel();
return err; return err;
} }
if (pf->kind == CHANNEL) { if (pf->kind == CHANNEL) {
struct channel *pch = PF_TO_CHANNEL(pf); struct channel *pch;
struct ppp_channel *chan; struct ppp_channel *chan;
lock_kernel();
pch = PF_TO_CHANNEL(pf);
switch (cmd) { switch (cmd) {
case PPPIOCCONNECT: case PPPIOCCONNECT:
if (get_user(unit, p)) if (get_user(unit, p))
...@@ -611,6 +615,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file, ...@@ -611,6 +615,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file,
err = chan->ops->ioctl(chan, cmd, arg); err = chan->ops->ioctl(chan, cmd, arg);
up_read(&pch->chan_sem); up_read(&pch->chan_sem);
} }
unlock_kernel();
return err; return err;
} }
...@@ -620,6 +625,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file, ...@@ -620,6 +625,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file,
return -EINVAL; return -EINVAL;
} }
lock_kernel();
ppp = PF_TO_PPP(pf); ppp = PF_TO_PPP(pf);
switch (cmd) { switch (cmd) {
case PPPIOCSMRU: case PPPIOCSMRU:
...@@ -767,7 +773,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file, ...@@ -767,7 +773,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file,
default: default:
err = -ENOTTY; err = -ENOTTY;
} }
unlock_kernel();
return err; return err;
} }
...@@ -779,6 +785,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file, ...@@ -779,6 +785,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file,
struct channel *chan; struct channel *chan;
int __user *p = (int __user *)arg; int __user *p = (int __user *)arg;
lock_kernel();
switch (cmd) { switch (cmd) {
case PPPIOCNEWUNIT: case PPPIOCNEWUNIT:
/* Create a new ppp unit */ /* Create a new ppp unit */
...@@ -827,6 +834,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file, ...@@ -827,6 +834,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file,
default: default:
err = -ENOTTY; err = -ENOTTY;
} }
unlock_kernel();
return err; return err;
} }
...@@ -835,7 +843,7 @@ static const struct file_operations ppp_device_fops = { ...@@ -835,7 +843,7 @@ static const struct file_operations ppp_device_fops = {
.read = ppp_read, .read = ppp_read,
.write = ppp_write, .write = ppp_write,
.poll = ppp_poll, .poll = ppp_poll,
.ioctl = ppp_ioctl, .unlocked_ioctl = ppp_ioctl,
.open = ppp_open, .open = ppp_open,
.release = ppp_release .release = ppp_release
}; };
......
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