Skip to content

Commit a71bfc0

Browse files
committed
Merge branch 'asm-generic-uaccess-7' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic into asm-generic
These two functions appear to be unnecessarily different between architectures, and the asm-generic version is a bit questionable, even for NOMMU architectures. Clean this up to just use the generic library version for anything that uses the generic version today. I've expanded on the patch descriptions a little, as suggested by Christoph Hellwig, but I suspect a more detailed review would uncover additional problems with the custom versions that are getting removed. I ended up adding patches for csky and microblaze as they had the same implementation that I removed elsewhere, these are now gone as well. * 'asm-generic-uaccess-7' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic: asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols asm-generic: remove extra strn{cpy_from,len}_user declarations asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user s390: use generic strncpy/strnlen from_user microblaze: use generic strncpy/strnlen from_user csky: use generic strncpy/strnlen from_user arc: use generic strncpy/strnlen from_user hexagon: use generic strncpy/strnlen from_user h8300: remove stale strncpy_from_user asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user Signed-off-by: Arnd Bergmann <[email protected]>
2 parents fc062ad + e622699 commit a71bfc0

File tree

39 files changed

+47
-648
lines changed

39 files changed

+47
-648
lines changed

arch/alpha/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ config ALPHA
2929
select AUDIT_ARCH
3030
select GENERIC_CPU_VULNERABILITIES
3131
select GENERIC_SMP_IDLE_THREAD
32-
select GENERIC_STRNCPY_FROM_USER
33-
select GENERIC_STRNLEN_USER
3432
select HAVE_ARCH_AUDITSYSCALL
3533
select HAVE_MOD_ARCH_SPECIFIC
3634
select MODULES_USE_ELF_RELA

arch/arc/include/asm/uaccess.h

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -655,88 +655,16 @@ static inline unsigned long __arc_clear_user(void __user *to, unsigned long n)
655655
return res;
656656
}
657657

658-
static inline long
659-
__arc_strncpy_from_user(char *dst, const char __user *src, long count)
660-
{
661-
long res = 0;
662-
char val;
663-
664-
if (count == 0)
665-
return 0;
666-
667-
__asm__ __volatile__(
668-
" mov lp_count, %5 \n"
669-
" lp 3f \n"
670-
"1: ldb.ab %3, [%2, 1] \n"
671-
" breq.d %3, 0, 3f \n"
672-
" stb.ab %3, [%1, 1] \n"
673-
" add %0, %0, 1 # Num of NON NULL bytes copied \n"
674-
"3: \n"
675-
" .section .fixup, \"ax\" \n"
676-
" .align 4 \n"
677-
"4: mov %0, %4 # sets @res as -EFAULT \n"
678-
" j 3b \n"
679-
" .previous \n"
680-
" .section __ex_table, \"a\" \n"
681-
" .align 4 \n"
682-
" .word 1b, 4b \n"
683-
" .previous \n"
684-
: "+r"(res), "+r"(dst), "+r"(src), "=r"(val)
685-
: "g"(-EFAULT), "r"(count)
686-
: "lp_count", "memory");
687-
688-
return res;
689-
}
690-
691-
static inline long __arc_strnlen_user(const char __user *s, long n)
692-
{
693-
long res, tmp1, cnt;
694-
char val;
695-
696-
__asm__ __volatile__(
697-
" mov %2, %1 \n"
698-
"1: ldb.ab %3, [%0, 1] \n"
699-
" breq.d %3, 0, 2f \n"
700-
" sub.f %2, %2, 1 \n"
701-
" bnz 1b \n"
702-
" sub %2, %2, 1 \n"
703-
"2: sub %0, %1, %2 \n"
704-
"3: ;nop \n"
705-
" .section .fixup, \"ax\" \n"
706-
" .align 4 \n"
707-
"4: mov %0, 0 \n"
708-
" j 3b \n"
709-
" .previous \n"
710-
" .section __ex_table, \"a\" \n"
711-
" .align 4 \n"
712-
" .word 1b, 4b \n"
713-
" .previous \n"
714-
: "=r"(res), "=r"(tmp1), "=r"(cnt), "=r"(val)
715-
: "0"(s), "1"(n)
716-
: "memory");
717-
718-
return res;
719-
}
720-
721658
#ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
722659

723660
#define INLINE_COPY_TO_USER
724661
#define INLINE_COPY_FROM_USER
725662

726663
#define __clear_user(d, n) __arc_clear_user(d, n)
727-
#define __strncpy_from_user(d, s, n) __arc_strncpy_from_user(d, s, n)
728-
#define __strnlen_user(s, n) __arc_strnlen_user(s, n)
729664
#else
730665
extern unsigned long arc_clear_user_noinline(void __user *to,
731666
unsigned long n);
732-
extern long arc_strncpy_from_user_noinline (char *dst, const char __user *src,
733-
long count);
734-
extern long arc_strnlen_user_noinline(const char __user *src, long n);
735-
736667
#define __clear_user(d, n) arc_clear_user_noinline(d, n)
737-
#define __strncpy_from_user(d, s, n) arc_strncpy_from_user_noinline(d, s, n)
738-
#define __strnlen_user(s, n) arc_strnlen_user_noinline(s, n)
739-
740668
#endif
741669

742670
#include <asm/segment.h>

arch/arc/mm/extable.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,4 @@ unsigned long arc_clear_user_noinline(void __user *to,
3232
}
3333
EXPORT_SYMBOL(arc_clear_user_noinline);
3434

35-
long arc_strncpy_from_user_noinline(char *dst, const char __user *src,
36-
long count)
37-
{
38-
return __arc_strncpy_from_user(dst, src, count);
39-
}
40-
EXPORT_SYMBOL(arc_strncpy_from_user_noinline);
41-
42-
long arc_strnlen_user_noinline(const char __user *src, long n)
43-
{
44-
return __arc_strnlen_user(src, n);
45-
}
46-
EXPORT_SYMBOL(arc_strnlen_user_noinline);
4735
#endif

arch/arm/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ config ARM
6363
select GENERIC_PCI_IOMAP
6464
select GENERIC_SCHED_CLOCK
6565
select GENERIC_SMP_IDLE_THREAD
66-
select GENERIC_STRNCPY_FROM_USER
67-
select GENERIC_STRNLEN_USER
6866
select HANDLE_DOMAIN_IRQ
6967
select HARDIRQS_SW_RESEND
7068
select HAVE_ARCH_AUDITSYSCALL if AEABI && !OABI_COMPAT

arch/arm64/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ config ARM64
130130
select GENERIC_PTDUMP
131131
select GENERIC_SCHED_CLOCK
132132
select GENERIC_SMP_IDLE_THREAD
133-
select GENERIC_STRNCPY_FROM_USER
134-
select GENERIC_STRNLEN_USER
135133
select GENERIC_TIME_VSYSCALL
136134
select GENERIC_GETTIMEOFDAY
137135
select GENERIC_VDSO_TIME_NS

arch/csky/include/asm/uaccess.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,6 @@ unsigned long raw_copy_to_user(void *to, const void *from, unsigned long n);
209209
unsigned long __clear_user(void __user *to, unsigned long n);
210210
#define __clear_user __clear_user
211211

212-
long __strncpy_from_user(char *dst, const char *src, long count);
213-
#define __strncpy_from_user __strncpy_from_user
214-
215-
long __strnlen_user(const char *s, long n);
216-
#define __strnlen_user __strnlen_user
217-
218212
#include <asm/segment.h>
219213
#include <asm-generic/uaccess.h>
220214

arch/csky/lib/usercopy.c

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -142,108 +142,6 @@ unsigned long raw_copy_to_user(void *to, const void *from,
142142
}
143143
EXPORT_SYMBOL(raw_copy_to_user);
144144

145-
/*
146-
* __strncpy_from_user: - Copy a NUL terminated string from userspace,
147-
* with less checking.
148-
* @dst: Destination address, in kernel space. This buffer must be at
149-
* least @count bytes long.
150-
* @src: Source address, in user space.
151-
* @count: Maximum number of bytes to copy, including the trailing NUL.
152-
*
153-
* Copies a NUL-terminated string from userspace to kernel space.
154-
* Caller must check the specified block with access_ok() before calling
155-
* this function.
156-
*
157-
* On success, returns the length of the string (not including the trailing
158-
* NUL).
159-
*
160-
* If access to userspace fails, returns -EFAULT (some data may have been
161-
* copied).
162-
*
163-
* If @count is smaller than the length of the string, copies @count bytes
164-
* and returns @count.
165-
*/
166-
long __strncpy_from_user(char *dst, const char *src, long count)
167-
{
168-
long res, faultres;
169-
int tmp;
170-
171-
__asm__ __volatile__(
172-
" cmpnei %3, 0 \n"
173-
" bf 4f \n"
174-
"1: cmpnei %1, 0 \n"
175-
" bf 5f \n"
176-
"2: ldb %4, (%3, 0) \n"
177-
" stb %4, (%2, 0) \n"
178-
" cmpnei %4, 0 \n"
179-
" bf 3f \n"
180-
" addi %3, 1 \n"
181-
" addi %2, 1 \n"
182-
" subi %1, 1 \n"
183-
" br 1b \n"
184-
"3: subu %0, %1 \n"
185-
" br 5f \n"
186-
"4: mov %0, %5 \n"
187-
" br 5f \n"
188-
".section __ex_table, \"a\" \n"
189-
".align 2 \n"
190-
".long 2b, 4b \n"
191-
".previous \n"
192-
"5: \n"
193-
: "=r"(res), "=r"(count), "=r"(dst),
194-
"=r"(src), "=r"(tmp), "=r"(faultres)
195-
: "5"(-EFAULT), "0"(count), "1"(count),
196-
"2"(dst), "3"(src)
197-
: "memory");
198-
199-
return res;
200-
}
201-
EXPORT_SYMBOL(__strncpy_from_user);
202-
203-
/*
204-
* strnlen_user: - Get the size of a string in user space.
205-
* @str: The string to measure.
206-
* @n: The maximum valid length
207-
*
208-
* Get the size of a NUL-terminated string in user space.
209-
*
210-
* Returns the size of the string INCLUDING the terminating NUL.
211-
* On exception, returns 0.
212-
* If the string is too long, returns a value greater than @n.
213-
*/
214-
long __strnlen_user(const char *s, long n)
215-
{
216-
unsigned long res, tmp;
217-
218-
__asm__ __volatile__(
219-
" cmpnei %1, 0 \n"
220-
" bf 3f \n"
221-
"1: cmpnei %0, 0 \n"
222-
" bf 3f \n"
223-
"2: ldb %3, (%1, 0) \n"
224-
" cmpnei %3, 0 \n"
225-
" bf 3f \n"
226-
" subi %0, 1 \n"
227-
" addi %1, 1 \n"
228-
" br 1b \n"
229-
"3: subu %2, %0 \n"
230-
" addi %2, 1 \n"
231-
" br 5f \n"
232-
"4: movi %0, 0 \n"
233-
" br 5f \n"
234-
".section __ex_table, \"a\" \n"
235-
".align 2 \n"
236-
".long 2b, 4b \n"
237-
".previous \n"
238-
"5: \n"
239-
: "=r"(n), "=r"(s), "=r"(res), "=r"(tmp)
240-
: "0"(n), "1"(s), "2"(n)
241-
: "memory");
242-
243-
return res;
244-
}
245-
EXPORT_SYMBOL(__strnlen_user);
246-
247145
/*
248146
* __clear_user: - Zero a block of memory in user space, with less checking.
249147
* @to: Destination address, in user space.

arch/h8300/kernel/h8300_ksyms.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ asmlinkage long __mulsi3(long, long);
1919
asmlinkage long __udivsi3(long, long);
2020
asmlinkage void *memcpy(void *, const void *, size_t);
2121
asmlinkage void *memset(void *, int, size_t);
22-
asmlinkage long strncpy_from_user(void *to, void *from, size_t n);
2322

2423
/* gcc lib functions */
2524
EXPORT_SYMBOL(__ucmpdi2);
@@ -34,4 +33,3 @@ EXPORT_SYMBOL(__mulsi3);
3433
EXPORT_SYMBOL(__udivsi3);
3534
EXPORT_SYMBOL(memcpy);
3635
EXPORT_SYMBOL(memset);
37-
EXPORT_SYMBOL(strncpy_from_user);

arch/h8300/lib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Makefile for H8/300-specific library files..
44
#
55

6-
lib-y = memcpy.o memset.o abs.o strncpy.o \
6+
lib-y = memcpy.o memset.o abs.o \
77
mulsi3.o udivsi3.o muldi3.o moddivsi3.o \
88
ashldi3.o lshrdi3.o ashrdi3.o ucmpdi2.o \
99
delay.o

arch/h8300/lib/strncpy.S

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)