diff options
| author | Alan Cox <alan@redhat.com> | 2008-05-26 02:43:11 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2008-05-26 02:43:11 -0400 |
| commit | 54064600981ab0fe977b0e760732c30f4472d693 (patch) | |
| tree | a58d0325e593a148dc80eae84eef7ff1ad2523a8 /net/irda | |
| parent | 866988edacebb6f1982266b51fc344c969f481ec (diff) | |
irda: Push BKL down into irda ioctl handlers
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/irda')
| -rw-r--r-- | net/irda/irnet/irnet_ppp.c | 54 | ||||
| -rw-r--r-- | net/irda/irnet/irnet_ppp.h | 7 |
2 files changed, 33 insertions, 28 deletions
diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c index e0eab5927c4f..f6e54fa97f47 100644 --- a/net/irda/irnet/irnet_ppp.c +++ b/net/irda/irnet/irnet_ppp.c | |||
| @@ -628,8 +628,8 @@ dev_irnet_poll(struct file * file, | |||
| 628 | * This is the way pppd configure us and control us while the PPP | 628 | * This is the way pppd configure us and control us while the PPP |
| 629 | * instance is active. | 629 | * instance is active. |
| 630 | */ | 630 | */ |
| 631 | static int | 631 | static long |
| 632 | dev_irnet_ioctl(struct inode * inode, | 632 | dev_irnet_ioctl( |
| 633 | struct file * file, | 633 | struct file * file, |
| 634 | unsigned int cmd, | 634 | unsigned int cmd, |
| 635 | unsigned long arg) | 635 | unsigned long arg) |
| @@ -660,6 +660,7 @@ dev_irnet_ioctl(struct inode * inode, | |||
| 660 | { | 660 | { |
| 661 | DEBUG(FS_INFO, "Entering PPP discipline.\n"); | 661 | DEBUG(FS_INFO, "Entering PPP discipline.\n"); |
| 662 | /* PPP channel setup (ap->chan in configued in dev_irnet_open())*/ | 662 | /* PPP channel setup (ap->chan in configued in dev_irnet_open())*/ |
| 663 | lock_kernel(); | ||
| 663 | err = ppp_register_channel(&ap->chan); | 664 | err = ppp_register_channel(&ap->chan); |
| 664 | if(err == 0) | 665 | if(err == 0) |
| 665 | { | 666 | { |
| @@ -672,12 +673,14 @@ dev_irnet_ioctl(struct inode * inode, | |||
| 672 | } | 673 | } |
| 673 | else | 674 | else |
| 674 | DERROR(FS_ERROR, "Can't setup PPP channel...\n"); | 675 | DERROR(FS_ERROR, "Can't setup PPP channel...\n"); |
| 676 | unlock_kernel(); | ||
| 675 | } | 677 | } |
| 676 | else | 678 | else |
| 677 | { | 679 | { |
| 678 | /* In theory, should be N_TTY */ | 680 | /* In theory, should be N_TTY */ |
| 679 | DEBUG(FS_INFO, "Exiting PPP discipline.\n"); | 681 | DEBUG(FS_INFO, "Exiting PPP discipline.\n"); |
| 680 | /* Disconnect from the generic PPP layer */ | 682 | /* Disconnect from the generic PPP layer */ |
| 683 | lock_kernel(); | ||
| 681 | if(ap->ppp_open) | 684 | if(ap->ppp_open) |
| 682 | { | 685 | { |
| 683 | ap->ppp_open = 0; | 686 | ap->ppp_open = 0; |
| @@ -686,24 +689,20 @@ dev_irnet_ioctl(struct inode * inode, | |||
| 686 | else | 689 | else |
| 687 | DERROR(FS_ERROR, "Channel not registered !\n"); | 690 | DERROR(FS_ERROR, "Channel not registered !\n"); |
| 688 | err = 0; | 691 | err = 0; |
| 692 | unlock_kernel(); | ||
| 689 | } | 693 | } |
| 690 | break; | 694 | break; |
| 691 | 695 | ||
| 692 | /* Query PPP channel and unit number */ | 696 | /* Query PPP channel and unit number */ |
| 693 | case PPPIOCGCHAN: | 697 | case PPPIOCGCHAN: |
| 694 | if(!ap->ppp_open) | 698 | if(ap->ppp_open && !put_user(ppp_channel_index(&ap->chan), |
| 695 | break; | 699 | (int __user *)argp)) |
| 696 | if(put_user(ppp_channel_index(&ap->chan), (int __user *)argp)) | 700 | err = 0; |
| 697 | break; | ||
| 698 | DEBUG(FS_INFO, "Query channel.\n"); | ||
| 699 | err = 0; | ||
| 700 | break; | 701 | break; |
| 701 | case PPPIOCGUNIT: | 702 | case PPPIOCGUNIT: |
| 702 | if(!ap->ppp_open) | 703 | lock_kernel(); |
| 703 | break; | 704 | if(ap->ppp_open && !put_user(ppp_unit_number(&ap->chan), |
| 704 | if(put_user(ppp_unit_number(&ap->chan), (int __user *)argp)) | 705 | (int __user *)argp)) |
| 705 | break; | ||
| 706 | DEBUG(FS_INFO, "Query unit number.\n"); | ||
| 707 | err = 0; | 706 | err = 0; |
| 708 | break; | 707 | break; |
| 709 | 708 | ||
| @@ -723,34 +722,39 @@ dev_irnet_ioctl(struct inode * inode, | |||
| 723 | DEBUG(FS_INFO, "Standard PPP ioctl.\n"); | 722 | DEBUG(FS_INFO, "Standard PPP ioctl.\n"); |
| 724 | if(!capable(CAP_NET_ADMIN)) | 723 | if(!capable(CAP_NET_ADMIN)) |
| 725 | err = -EPERM; | 724 | err = -EPERM; |
| 726 | else | 725 | else { |
| 726 | lock_kernel(); | ||
| 727 | err = ppp_irnet_ioctl(&ap->chan, cmd, arg); | 727 | err = ppp_irnet_ioctl(&ap->chan, cmd, arg); |
| 728 | unlock_kernel(); | ||
| 729 | } | ||
| 728 | break; | 730 | break; |
| 729 | 731 | ||
| 730 | /* TTY IOCTLs : Pretend that we are a tty, to keep pppd happy */ | 732 | /* TTY IOCTLs : Pretend that we are a tty, to keep pppd happy */ |
| 731 | /* Get termios */ | 733 | /* Get termios */ |
| 732 | case TCGETS: | 734 | case TCGETS: |
| 733 | DEBUG(FS_INFO, "Get termios.\n"); | 735 | DEBUG(FS_INFO, "Get termios.\n"); |
| 736 | lock_kernel(); | ||
| 734 | #ifndef TCGETS2 | 737 | #ifndef TCGETS2 |
| 735 | if(kernel_termios_to_user_termios((struct termios __user *)argp, &ap->termios)) | 738 | if(!kernel_termios_to_user_termios((struct termios __user *)argp, &ap->termios)) |
| 736 | break; | 739 | err = 0; |
| 737 | #else | 740 | #else |
| 738 | if(kernel_termios_to_user_termios_1((struct termios __user *)argp, &ap->termios)) | 741 | if(kernel_termios_to_user_termios_1((struct termios __user *)argp, &ap->termios)) |
| 739 | break; | 742 | err = 0; |
| 740 | #endif | 743 | #endif |
| 741 | err = 0; | 744 | unlock_kernel(); |
| 742 | break; | 745 | break; |
| 743 | /* Set termios */ | 746 | /* Set termios */ |
| 744 | case TCSETSF: | 747 | case TCSETSF: |
| 745 | DEBUG(FS_INFO, "Set termios.\n"); | 748 | DEBUG(FS_INFO, "Set termios.\n"); |
| 749 | lock_kernel(); | ||
| 746 | #ifndef TCGETS2 | 750 | #ifndef TCGETS2 |
| 747 | if(user_termios_to_kernel_termios(&ap->termios, (struct termios __user *)argp)) | 751 | if(!user_termios_to_kernel_termios(&ap->termios, (struct termios __user *)argp)) |
| 748 | break; | 752 | err = 0; |
| 749 | #else | 753 | #else |
| 750 | if(user_termios_to_kernel_termios_1(&ap->termios, (struct termios __user *)argp)) | 754 | if(!user_termios_to_kernel_termios_1(&ap->termios, (struct termios __user *)argp)) |
| 751 | break; | 755 | err = 0; |
| 752 | #endif | 756 | #endif |
| 753 | err = 0; | 757 | unlock_kernel(); |
| 754 | break; | 758 | break; |
| 755 | 759 | ||
| 756 | /* Set DTR/RTS */ | 760 | /* Set DTR/RTS */ |
| @@ -773,7 +777,9 @@ dev_irnet_ioctl(struct inode * inode, | |||
| 773 | * We should also worry that we don't accept junk here and that | 777 | * We should also worry that we don't accept junk here and that |
| 774 | * we get rid of our own buffers */ | 778 | * we get rid of our own buffers */ |
| 775 | #ifdef FLUSH_TO_PPP | 779 | #ifdef FLUSH_TO_PPP |
| 780 | lock_kernel(); | ||
| 776 | ppp_output_wakeup(&ap->chan); | 781 | ppp_output_wakeup(&ap->chan); |
| 782 | unlock_kernel(); | ||
| 777 | #endif /* FLUSH_TO_PPP */ | 783 | #endif /* FLUSH_TO_PPP */ |
| 778 | err = 0; | 784 | err = 0; |
| 779 | break; | 785 | break; |
| @@ -788,7 +794,7 @@ dev_irnet_ioctl(struct inode * inode, | |||
| 788 | 794 | ||
| 789 | default: | 795 | default: |
| 790 | DERROR(FS_ERROR, "Unsupported ioctl (0x%X)\n", cmd); | 796 | DERROR(FS_ERROR, "Unsupported ioctl (0x%X)\n", cmd); |
| 791 | err = -ENOIOCTLCMD; | 797 | err = -ENOTTY; |
| 792 | } | 798 | } |
| 793 | 799 | ||
| 794 | DEXIT(FS_TRACE, " - err = 0x%X\n", err); | 800 | DEXIT(FS_TRACE, " - err = 0x%X\n", err); |
diff --git a/net/irda/irnet/irnet_ppp.h b/net/irda/irnet/irnet_ppp.h index d2beb7df8f7f..d9f8bd4ebd05 100644 --- a/net/irda/irnet/irnet_ppp.h +++ b/net/irda/irnet/irnet_ppp.h | |||
| @@ -76,9 +76,8 @@ static ssize_t | |||
| 76 | static unsigned int | 76 | static unsigned int |
| 77 | dev_irnet_poll(struct file *, | 77 | dev_irnet_poll(struct file *, |
| 78 | poll_table *); | 78 | poll_table *); |
| 79 | static int | 79 | static long |
| 80 | dev_irnet_ioctl(struct inode *, | 80 | dev_irnet_ioctl(struct file *, |
| 81 | struct file *, | ||
| 82 | unsigned int, | 81 | unsigned int, |
| 83 | unsigned long); | 82 | unsigned long); |
| 84 | /* ------------------------ PPP INTERFACE ------------------------ */ | 83 | /* ------------------------ PPP INTERFACE ------------------------ */ |
| @@ -102,7 +101,7 @@ static struct file_operations irnet_device_fops = | |||
| 102 | .read = dev_irnet_read, | 101 | .read = dev_irnet_read, |
| 103 | .write = dev_irnet_write, | 102 | .write = dev_irnet_write, |
| 104 | .poll = dev_irnet_poll, | 103 | .poll = dev_irnet_poll, |
| 105 | .ioctl = dev_irnet_ioctl, | 104 | .unlocked_ioctl = dev_irnet_ioctl, |
| 106 | .open = dev_irnet_open, | 105 | .open = dev_irnet_open, |
| 107 | .release = dev_irnet_close | 106 | .release = dev_irnet_close |
| 108 | /* Also : llseek, readdir, mmap, flush, fsync, fasync, lock, readv, writev */ | 107 | /* Also : llseek, readdir, mmap, flush, fsync, fasync, lock, readv, writev */ |
