@@ -270,7 +270,7 @@ static void ppp_mp_insert(struct ppp *ppp, struct sk_buff *skb);
270
270
static struct sk_buff * ppp_mp_reconstruct (struct ppp * ppp );
271
271
static int ppp_mp_explode (struct ppp * ppp , struct sk_buff * skb );
272
272
#endif /* CONFIG_PPP_MULTILINK */
273
- static int ppp_set_compress (struct ppp * ppp , unsigned long arg );
273
+ static int ppp_set_compress (struct ppp * ppp , struct ppp_option_data * data );
274
274
static void ppp_ccp_peek (struct ppp * ppp , struct sk_buff * skb , int inbound );
275
275
static void ppp_ccp_closed (struct ppp * ppp );
276
276
static struct compressor * find_compressor (int type );
@@ -708,9 +708,14 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
708
708
break ;
709
709
710
710
case PPPIOCSCOMPRESS :
711
- err = ppp_set_compress (ppp , arg );
711
+ {
712
+ struct ppp_option_data data ;
713
+ if (copy_from_user (& data , argp , sizeof (data )))
714
+ err = - EFAULT ;
715
+ else
716
+ err = ppp_set_compress (ppp , & data );
712
717
break ;
713
-
718
+ }
714
719
case PPPIOCGUNIT :
715
720
if (put_user (ppp -> file .index , p ))
716
721
break ;
@@ -827,6 +832,13 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
827
832
}
828
833
829
834
#ifdef CONFIG_COMPAT
835
+ struct ppp_option_data32 {
836
+ compat_uptr_t ptr ;
837
+ u32 length ;
838
+ compat_int_t transmit ;
839
+ };
840
+ #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
841
+
830
842
static long ppp_compat_ioctl (struct file * file , unsigned int cmd , unsigned long arg )
831
843
{
832
844
struct ppp_file * pf ;
@@ -863,6 +875,21 @@ static long ppp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long
863
875
break ;
864
876
}
865
877
#endif /* CONFIG_PPP_FILTER */
878
+ case PPPIOCSCOMPRESS32 :
879
+ {
880
+ struct ppp_option_data32 data32 ;
881
+ if (copy_from_user (& data32 , argp , sizeof (data32 ))) {
882
+ err = - EFAULT ;
883
+ } else {
884
+ struct ppp_option_data data = {
885
+ .ptr = compat_ptr (data32 .ptr ),
886
+ .length = data32 .length ,
887
+ .transmit = data32 .transmit
888
+ };
889
+ err = ppp_set_compress (ppp , & data );
890
+ }
891
+ break ;
892
+ }
866
893
}
867
894
}
868
895
mutex_unlock (& ppp_mutex );
@@ -2783,24 +2810,20 @@ ppp_output_wakeup(struct ppp_channel *chan)
2783
2810
2784
2811
/* Process the PPPIOCSCOMPRESS ioctl. */
2785
2812
static int
2786
- ppp_set_compress (struct ppp * ppp , unsigned long arg )
2813
+ ppp_set_compress (struct ppp * ppp , struct ppp_option_data * data )
2787
2814
{
2788
- int err ;
2815
+ int err = - EFAULT ;
2789
2816
struct compressor * cp , * ocomp ;
2790
- struct ppp_option_data data ;
2791
2817
void * state , * ostate ;
2792
2818
unsigned char ccp_option [CCP_MAX_OPTION_LENGTH ];
2793
2819
2794
- err = - EFAULT ;
2795
- if (copy_from_user (& data , (void __user * ) arg , sizeof (data )))
2796
- goto out ;
2797
- if (data .length > CCP_MAX_OPTION_LENGTH )
2820
+ if (data -> length > CCP_MAX_OPTION_LENGTH )
2798
2821
goto out ;
2799
- if (copy_from_user (ccp_option , ( void __user * ) data . ptr , data . length ))
2822
+ if (copy_from_user (ccp_option , data -> ptr , data -> length ))
2800
2823
goto out ;
2801
2824
2802
2825
err = - EINVAL ;
2803
- if (data . length < 2 || ccp_option [1 ] < 2 || ccp_option [1 ] > data . length )
2826
+ if (data -> length < 2 || ccp_option [1 ] < 2 || ccp_option [1 ] > data -> length )
2804
2827
goto out ;
2805
2828
2806
2829
cp = try_then_request_module (
@@ -2810,8 +2833,8 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg)
2810
2833
goto out ;
2811
2834
2812
2835
err = - ENOBUFS ;
2813
- if (data . transmit ) {
2814
- state = cp -> comp_alloc (ccp_option , data . length );
2836
+ if (data -> transmit ) {
2837
+ state = cp -> comp_alloc (ccp_option , data -> length );
2815
2838
if (state ) {
2816
2839
ppp_xmit_lock (ppp );
2817
2840
ppp -> xstate &= ~SC_COMP_RUN ;
@@ -2829,7 +2852,7 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg)
2829
2852
module_put (cp -> owner );
2830
2853
2831
2854
} else {
2832
- state = cp -> decomp_alloc (ccp_option , data . length );
2855
+ state = cp -> decomp_alloc (ccp_option , data -> length );
2833
2856
if (state ) {
2834
2857
ppp_recv_lock (ppp );
2835
2858
ppp -> rstate &= ~SC_DECOMP_RUN ;
0 commit comments