@@ -92,33 +92,58 @@ static inline unsigned long extable_fixup(const struct exception_table_entry *x)
9292#define ARCH_HAS_SORT_EXTABLE
9393#define ARCH_HAS_SEARCH_EXTABLE
9494
95- struct uaccess_ops {
96- size_t (* copy_from_user )(void * , const void __user * , size_t );
97- size_t (* copy_to_user )(void __user * , const void * , size_t );
98- size_t (* copy_in_user )(void __user * , const void __user * , size_t );
99- size_t (* clear_user )(void __user * , size_t );
100- size_t (* strnlen_user )(const char __user * , size_t );
101- size_t (* strncpy_from_user )(char * , const char __user * , size_t );
102- int (* futex_atomic_op )(int op , u32 __user * , int oparg , int * old );
103- int (* futex_atomic_cmpxchg )(u32 * , u32 __user * , u32 old , u32 new );
104- };
95+ int __handle_fault (unsigned long , unsigned long , int );
10596
106- extern struct uaccess_ops uaccess ;
107- extern struct uaccess_ops uaccess_mvcos ;
108- extern struct uaccess_ops uaccess_pt ;
97+ /**
98+ * __copy_from_user: - Copy a block of data from user space, with less checking.
99+ * @to: Destination address, in kernel space.
100+ * @from: Source address, in user space.
101+ * @n: Number of bytes to copy.
102+ *
103+ * Context: User context only. This function may sleep.
104+ *
105+ * Copy data from user space to kernel space. Caller must check
106+ * the specified block with access_ok() before calling this function.
107+ *
108+ * Returns number of bytes that could not be copied.
109+ * On success, this will be zero.
110+ *
111+ * If some data could not be copied, this function will pad the copied
112+ * data to the requested size using zero bytes.
113+ */
114+ size_t __must_check __copy_from_user (void * to , const void __user * from ,
115+ size_t n );
116+
117+ /**
118+ * __copy_to_user: - Copy a block of data into user space, with less checking.
119+ * @to: Destination address, in user space.
120+ * @from: Source address, in kernel space.
121+ * @n: Number of bytes to copy.
122+ *
123+ * Context: User context only. This function may sleep.
124+ *
125+ * Copy data from kernel space to user space. Caller must check
126+ * the specified block with access_ok() before calling this function.
127+ *
128+ * Returns number of bytes that could not be copied.
129+ * On success, this will be zero.
130+ */
131+ unsigned long __must_check __copy_to_user (void __user * to , const void * from ,
132+ unsigned long n );
109133
110- extern int __handle_fault (unsigned long , unsigned long , int );
134+ #define __copy_to_user_inatomic __copy_to_user
135+ #define __copy_from_user_inatomic __copy_from_user
111136
112137static inline int __put_user_fn (void * x , void __user * ptr , size_t size )
113138{
114- size = uaccess . copy_to_user (ptr , x , size );
115- return size ? - EFAULT : size ;
139+ size = __copy_to_user (ptr , x , size );
140+ return size ? - EFAULT : 0 ;
116141}
117142
118143static inline int __get_user_fn (void * x , const void __user * ptr , size_t size )
119144{
120- size = uaccess . copy_from_user (x , ptr , size );
121- return size ? - EFAULT : size ;
145+ size = __copy_from_user (x , ptr , size );
146+ return size ? - EFAULT : 0 ;
122147}
123148
124149/*
@@ -152,7 +177,7 @@ static inline int __get_user_fn(void *x, const void __user *ptr, size_t size)
152177})
153178
154179
155- extern int __put_user_bad (void ) __attribute__((noreturn ));
180+ int __put_user_bad (void ) __attribute__((noreturn ));
156181
157182#define __get_user (x , ptr ) \
158183({ \
@@ -200,34 +225,11 @@ extern int __put_user_bad(void) __attribute__((noreturn));
200225 __get_user(x, ptr); \
201226})
202227
203- extern int __get_user_bad (void ) __attribute__((noreturn ));
228+ int __get_user_bad (void ) __attribute__((noreturn ));
204229
205230#define __put_user_unaligned __put_user
206231#define __get_user_unaligned __get_user
207232
208- /**
209- * __copy_to_user: - Copy a block of data into user space, with less checking.
210- * @to: Destination address, in user space.
211- * @from: Source address, in kernel space.
212- * @n: Number of bytes to copy.
213- *
214- * Context: User context only. This function may sleep.
215- *
216- * Copy data from kernel space to user space. Caller must check
217- * the specified block with access_ok() before calling this function.
218- *
219- * Returns number of bytes that could not be copied.
220- * On success, this will be zero.
221- */
222- static inline unsigned long __must_check
223- __copy_to_user (void __user * to , const void * from , unsigned long n )
224- {
225- return uaccess .copy_to_user (to , from , n );
226- }
227-
228- #define __copy_to_user_inatomic __copy_to_user
229- #define __copy_from_user_inatomic __copy_from_user
230-
231233/**
232234 * copy_to_user: - Copy a block of data into user space.
233235 * @to: Destination address, in user space.
@@ -248,30 +250,7 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
248250 return __copy_to_user (to , from , n );
249251}
250252
251- /**
252- * __copy_from_user: - Copy a block of data from user space, with less checking.
253- * @to: Destination address, in kernel space.
254- * @from: Source address, in user space.
255- * @n: Number of bytes to copy.
256- *
257- * Context: User context only. This function may sleep.
258- *
259- * Copy data from user space to kernel space. Caller must check
260- * the specified block with access_ok() before calling this function.
261- *
262- * Returns number of bytes that could not be copied.
263- * On success, this will be zero.
264- *
265- * If some data could not be copied, this function will pad the copied
266- * data to the requested size using zero bytes.
267- */
268- static inline unsigned long __must_check
269- __copy_from_user (void * to , const void __user * from , unsigned long n )
270- {
271- return uaccess .copy_from_user (to , from , n );
272- }
273-
274- extern void copy_from_user_overflow (void )
253+ void copy_from_user_overflow (void )
275254#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
276255__compiletime_warning ("copy_from_user() buffer size is not provably correct" )
277256#endif
@@ -306,11 +285,8 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
306285 return __copy_from_user (to , from , n );
307286}
308287
309- static inline unsigned long __must_check
310- __copy_in_user (void __user * to , const void __user * from , unsigned long n )
311- {
312- return uaccess .copy_in_user (to , from , n );
313- }
288+ unsigned long __must_check
289+ __copy_in_user (void __user * to , const void __user * from , unsigned long n );
314290
315291static inline unsigned long __must_check
316292copy_in_user (void __user * to , const void __user * from , unsigned long n )
@@ -322,18 +298,22 @@ copy_in_user(void __user *to, const void __user *from, unsigned long n)
322298/*
323299 * Copy a null terminated string from userspace.
324300 */
301+
302+ long __strncpy_from_user (char * dst , const char __user * src , long count );
303+
325304static inline long __must_check
326305strncpy_from_user (char * dst , const char __user * src , long count )
327306{
328307 might_fault ();
329- return uaccess . strncpy_from_user (dst , src , count );
308+ return __strncpy_from_user (dst , src , count );
330309}
331310
332- static inline unsigned long
333- strnlen_user (const char __user * src , unsigned long n )
311+ size_t __must_check __strnlen_user (const char __user * src , size_t count );
312+
313+ static inline size_t strnlen_user (const char __user * src , size_t n )
334314{
335315 might_fault ();
336- return uaccess . strnlen_user (src , n );
316+ return __strnlen_user (src , n );
337317}
338318
339319/**
@@ -355,21 +335,15 @@ strnlen_user(const char __user * src, unsigned long n)
355335/*
356336 * Zero Userspace
357337 */
338+ size_t __must_check __clear_user (void __user * to , size_t size );
358339
359- static inline unsigned long __must_check
360- __clear_user (void __user * to , unsigned long n )
361- {
362- return uaccess .clear_user (to , n );
363- }
364-
365- static inline unsigned long __must_check
366- clear_user (void __user * to , unsigned long n )
340+ static inline size_t __must_check clear_user (void __user * to , size_t n )
367341{
368342 might_fault ();
369- return uaccess . clear_user (to , n );
343+ return __clear_user (to , n );
370344}
371345
372- extern int copy_to_user_real (void __user * dest , void * src , size_t count );
373- extern int copy_from_user_real (void * dest , void __user * src , size_t count );
346+ int copy_to_user_real (void __user * dest , void * src , size_t count );
347+ int copy_from_user_real (void * dest , void __user * src , size_t count );
374348
375349#endif /* __S390_UACCESS_H */
0 commit comments