@@ -2979,39 +2979,10 @@ static void shrink_submounts(struct mount *mnt)
2979
2979
}
2980
2980
}
2981
2981
2982
- /*
2983
- * Some copy_from_user() implementations do not return the exact number of
2984
- * bytes remaining to copy on a fault. But copy_mount_options() requires that.
2985
- * Note that this function differs from copy_from_user() in that it will oops
2986
- * on bad values of `to', rather than returning a short copy.
2987
- */
2988
- static long exact_copy_from_user (void * to , const void __user * from ,
2989
- unsigned long n )
2990
- {
2991
- char * t = to ;
2992
- const char __user * f = from ;
2993
- char c ;
2994
-
2995
- if (!access_ok (from , n ))
2996
- return n ;
2997
-
2998
- while (n ) {
2999
- if (__get_user (c , f )) {
3000
- memset (t , 0 , n );
3001
- break ;
3002
- }
3003
- * t ++ = c ;
3004
- f ++ ;
3005
- n -- ;
3006
- }
3007
- return n ;
3008
- }
3009
-
3010
2982
void * copy_mount_options (const void __user * data )
3011
2983
{
3012
- int i ;
3013
- unsigned long size ;
3014
2984
char * copy ;
2985
+ unsigned size ;
3015
2986
3016
2987
if (!data )
3017
2988
return NULL ;
@@ -3020,22 +2991,16 @@ void *copy_mount_options(const void __user * data)
3020
2991
if (!copy )
3021
2992
return ERR_PTR (- ENOMEM );
3022
2993
3023
- /* We only care that *some* data at the address the user
3024
- * gave us is valid. Just in case, we'll zero
3025
- * the remainder of the page.
3026
- */
3027
- /* copy_from_user cannot cross TASK_SIZE ! */
3028
- size = TASK_SIZE - (unsigned long )untagged_addr (data );
3029
- if (size > PAGE_SIZE )
3030
- size = PAGE_SIZE ;
2994
+ size = PAGE_SIZE - offset_in_page (data );
3031
2995
3032
- i = size - exact_copy_from_user (copy , data , size );
3033
- if (!i ) {
2996
+ if (copy_from_user (copy , data , size )) {
3034
2997
kfree (copy );
3035
2998
return ERR_PTR (- EFAULT );
3036
2999
}
3037
- if (i != PAGE_SIZE )
3038
- memset (copy + i , 0 , PAGE_SIZE - i );
3000
+ if (size != PAGE_SIZE ) {
3001
+ if (copy_from_user (copy + size , data + size , PAGE_SIZE - size ))
3002
+ memset (copy + size , 0 , PAGE_SIZE - size );
3003
+ }
3039
3004
return copy ;
3040
3005
}
3041
3006
0 commit comments