Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kill strlen_user()

no callers, no consistent semantics, no sane way to use it...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 82985258 2ea659a9

+2 -465
-1
arch/alpha/include/asm/uaccess.h
··· 326 326 (uaccess_kernel() ? ~0UL : TASK_SIZE) 327 327 328 328 extern long strncpy_from_user(char *dest, const char __user *src, long count); 329 - extern __must_check long strlen_user(const char __user *str); 330 329 extern __must_check long strnlen_user(const char __user *str, long n); 331 330 332 331 #include <asm/extable.h>
-1
arch/arm/include/asm/uaccess.h
··· 526 526 /* These are from lib/ code, and use __get_user() and friends */ 527 527 extern long strncpy_from_user(char *dest, const char __user *src, long count); 528 528 529 - extern __must_check long strlen_user(const char __user *str); 530 529 extern __must_check long strnlen_user(const char __user *str, long n); 531 530 532 531 #endif /* _ASMARM_UACCESS_H */
-1
arch/arm64/include/asm/uaccess.h
··· 349 349 350 350 extern long strncpy_from_user(char *dest, const char __user *src, long count); 351 351 352 - extern __must_check long strlen_user(const char __user *str); 353 352 extern __must_check long strnlen_user(const char __user *str, long n); 354 353 355 354 #endif /* __ASM_UACCESS_H */
-7
arch/blackfin/include/asm/uaccess.h
··· 194 194 return strnlen((const char __force *)src, n) + 1; 195 195 } 196 196 197 - static inline long __must_check strlen_user(const char __user *src) 198 - { 199 - if (!access_ok(VERIFY_READ, src, 1)) 200 - return 0; 201 - return strlen((const char __force *)src) + 1; 202 - } 203 - 204 197 /* 205 198 * Zero Userspace 206 199 */
-2
arch/cris/include/asm/uaccess.h
··· 363 363 return __do_clear_user(to, n); 364 364 } 365 365 366 - #define strlen_user(str) strnlen_user((str), 0x7ffffffe) 367 - 368 366 #endif /* _CRIS_UACCESS_H */
-2
arch/frv/include/asm/uaccess.h
··· 282 282 extern long strncpy_from_user(char *dst, const char __user *src, long count); 283 283 extern long strnlen_user(const char __user *src, long count); 284 284 285 - #define strlen_user(str) strnlen_user(str, 32767) 286 - 287 285 #endif /* _ASM_UACCESS_H */
-12
arch/ia64/include/asm/uaccess.h
··· 277 277 __sfu_ret; \ 278 278 }) 279 279 280 - /* Returns: 0 if bad, string length+1 (memory size) of string if ok */ 281 - extern unsigned long __strlen_user (const char __user *); 282 - 283 - #define strlen_user(str) \ 284 - ({ \ 285 - const char __user *__su_str = (str); \ 286 - unsigned long __su_ret = 0; \ 287 - if (__access_ok(__su_str, 0)) \ 288 - __su_ret = __strlen_user(__su_str); \ 289 - __su_ret; \ 290 - }) 291 - 292 280 /* 293 281 * Returns: 0 if exception before NUL or reaching the supplied limit 294 282 * (N), a value greater than N if the limit would be exceeded, else
+1 -1
arch/ia64/lib/Makefile
··· 5 5 lib-y := io.o __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o \ 6 6 __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o \ 7 7 checksum.o clear_page.o csum_partial_copy.o \ 8 - clear_user.o strncpy_from_user.o strlen_user.o strnlen_user.o \ 8 + clear_user.o strncpy_from_user.o strnlen_user.o \ 9 9 flush.o ip_fast_csum.o do_csum.o \ 10 10 memset.o strlen.o xor.o 11 11
-200
arch/ia64/lib/strlen_user.S
··· 1 - /* 2 - * Optimized version of the strlen_user() function 3 - * 4 - * Inputs: 5 - * in0 address of buffer 6 - * 7 - * Outputs: 8 - * ret0 0 in case of fault, strlen(buffer)+1 otherwise 9 - * 10 - * Copyright (C) 1998, 1999, 2001 Hewlett-Packard Co 11 - * David Mosberger-Tang <davidm@hpl.hp.com> 12 - * Stephane Eranian <eranian@hpl.hp.com> 13 - * 14 - * 01/19/99 S.Eranian heavily enhanced version (see details below) 15 - * 09/24/99 S.Eranian added speculation recovery code 16 - */ 17 - 18 - #include <asm/asmmacro.h> 19 - #include <asm/export.h> 20 - 21 - // 22 - // int strlen_user(char *) 23 - // ------------------------ 24 - // Returns: 25 - // - length of string + 1 26 - // - 0 in case an exception is raised 27 - // 28 - // This is an enhanced version of the basic strlen_user. it includes a 29 - // combination of compute zero index (czx), parallel comparisons, speculative 30 - // loads and loop unroll using rotating registers. 31 - // 32 - // General Ideas about the algorithm: 33 - // The goal is to look at the string in chunks of 8 bytes. 34 - // so we need to do a few extra checks at the beginning because the 35 - // string may not be 8-byte aligned. In this case we load the 8byte 36 - // quantity which includes the start of the string and mask the unused 37 - // bytes with 0xff to avoid confusing czx. 38 - // We use speculative loads and software pipelining to hide memory 39 - // latency and do read ahead safely. This way we defer any exception. 40 - // 41 - // Because we don't want the kernel to be relying on particular 42 - // settings of the DCR register, we provide recovery code in case 43 - // speculation fails. The recovery code is going to "redo" the work using 44 - // only normal loads. If we still get a fault then we return an 45 - // error (ret0=0). Otherwise we return the strlen+1 as usual. 46 - // The fact that speculation may fail can be caused, for instance, by 47 - // the DCR.dm bit being set. In this case TLB misses are deferred, i.e., 48 - // a NaT bit will be set if the translation is not present. The normal 49 - // load, on the other hand, will cause the translation to be inserted 50 - // if the mapping exists. 51 - // 52 - // It should be noted that we execute recovery code only when we need 53 - // to use the data that has been speculatively loaded: we don't execute 54 - // recovery code on pure read ahead data. 55 - // 56 - // Remarks: 57 - // - the cmp r0,r0 is used as a fast way to initialize a predicate 58 - // register to 1. This is required to make sure that we get the parallel 59 - // compare correct. 60 - // 61 - // - we don't use the epilogue counter to exit the loop but we need to set 62 - // it to zero beforehand. 63 - // 64 - // - after the loop we must test for Nat values because neither the 65 - // czx nor cmp instruction raise a NaT consumption fault. We must be 66 - // careful not to look too far for a Nat for which we don't care. 67 - // For instance we don't need to look at a NaT in val2 if the zero byte 68 - // was in val1. 69 - // 70 - // - Clearly performance tuning is required. 71 - // 72 - 73 - #define saved_pfs r11 74 - #define tmp r10 75 - #define base r16 76 - #define orig r17 77 - #define saved_pr r18 78 - #define src r19 79 - #define mask r20 80 - #define val r21 81 - #define val1 r22 82 - #define val2 r23 83 - 84 - GLOBAL_ENTRY(__strlen_user) 85 - .prologue 86 - .save ar.pfs, saved_pfs 87 - alloc saved_pfs=ar.pfs,11,0,0,8 88 - 89 - .rotr v[2], w[2] // declares our 4 aliases 90 - 91 - extr.u tmp=in0,0,3 // tmp=least significant 3 bits 92 - mov orig=in0 // keep trackof initial byte address 93 - dep src=0,in0,0,3 // src=8byte-aligned in0 address 94 - .save pr, saved_pr 95 - mov saved_pr=pr // preserve predicates (rotation) 96 - ;; 97 - 98 - .body 99 - 100 - ld8.s v[1]=[src],8 // load the initial 8bytes (must speculate) 101 - shl tmp=tmp,3 // multiply by 8bits/byte 102 - mov mask=-1 // our mask 103 - ;; 104 - ld8.s w[1]=[src],8 // load next 8 bytes in 2nd pipeline 105 - cmp.eq p6,p0=r0,r0 // sets p6 (required because of // cmp.and) 106 - sub tmp=64,tmp // how many bits to shift our mask on the right 107 - ;; 108 - shr.u mask=mask,tmp // zero enough bits to hold v[1] valuable part 109 - mov ar.ec=r0 // clear epilogue counter (saved in ar.pfs) 110 - ;; 111 - add base=-16,src // keep track of aligned base 112 - chk.s v[1], .recover // if already NaT, then directly skip to recover 113 - or v[1]=v[1],mask // now we have a safe initial byte pattern 114 - ;; 115 - 1: 116 - ld8.s v[0]=[src],8 // speculatively load next 117 - czx1.r val1=v[1] // search 0 byte from right 118 - czx1.r val2=w[1] // search 0 byte from right following 8bytes 119 - ;; 120 - ld8.s w[0]=[src],8 // speculatively load next to next 121 - cmp.eq.and p6,p0=8,val1 // p6 = p6 and val1==8 122 - cmp.eq.and p6,p0=8,val2 // p6 = p6 and mask==8 123 - (p6) br.wtop.dptk.few 1b // loop until p6 == 0 124 - ;; 125 - // 126 - // We must return try the recovery code iff 127 - // val1_is_nat || (val1==8 && val2_is_nat) 128 - // 129 - // XXX Fixme 130 - // - there must be a better way of doing the test 131 - // 132 - cmp.eq p8,p9=8,val1 // p6 = val1 had zero (disambiguate) 133 - tnat.nz p6,p7=val1 // test NaT on val1 134 - (p6) br.cond.spnt .recover // jump to recovery if val1 is NaT 135 - ;; 136 - // 137 - // if we come here p7 is true, i.e., initialized for // cmp 138 - // 139 - cmp.eq.and p7,p0=8,val1// val1==8? 140 - tnat.nz.and p7,p0=val2 // test NaT if val2 141 - (p7) br.cond.spnt .recover // jump to recovery if val2 is NaT 142 - ;; 143 - (p8) mov val1=val2 // val2 contains the value 144 - (p8) adds src=-16,src // correct position when 3 ahead 145 - (p9) adds src=-24,src // correct position when 4 ahead 146 - ;; 147 - sub ret0=src,orig // distance from origin 148 - sub tmp=7,val1 // 7=8-1 because this strlen returns strlen+1 149 - mov pr=saved_pr,0xffffffffffff0000 150 - ;; 151 - sub ret0=ret0,tmp // length=now - back -1 152 - mov ar.pfs=saved_pfs // because of ar.ec, restore no matter what 153 - br.ret.sptk.many rp // end of normal execution 154 - 155 - // 156 - // Outlined recovery code when speculation failed 157 - // 158 - // This time we don't use speculation and rely on the normal exception 159 - // mechanism. that's why the loop is not as good as the previous one 160 - // because read ahead is not possible 161 - // 162 - // XXX Fixme 163 - // - today we restart from the beginning of the string instead 164 - // of trying to continue where we left off. 165 - // 166 - .recover: 167 - EX(.Lexit1, ld8 val=[base],8) // load the initial bytes 168 - ;; 169 - or val=val,mask // remask first bytes 170 - cmp.eq p0,p6=r0,r0 // nullify first ld8 in loop 171 - ;; 172 - // 173 - // ar.ec is still zero here 174 - // 175 - 2: 176 - EX(.Lexit1, (p6) ld8 val=[base],8) 177 - ;; 178 - czx1.r val1=val // search 0 byte from right 179 - ;; 180 - cmp.eq p6,p0=8,val1 // val1==8 ? 181 - (p6) br.wtop.dptk.few 2b // loop until p6 == 0 182 - ;; 183 - sub ret0=base,orig // distance from base 184 - sub tmp=7,val1 // 7=8-1 because this strlen returns strlen+1 185 - mov pr=saved_pr,0xffffffffffff0000 186 - ;; 187 - sub ret0=ret0,tmp // length=now - back -1 188 - mov ar.pfs=saved_pfs // because of ar.ec, restore no matter what 189 - br.ret.sptk.many rp // end of successful recovery code 190 - 191 - // 192 - // We failed even on the normal load (called from exception handler) 193 - // 194 - .Lexit1: 195 - mov ret0=0 196 - mov pr=saved_pr,0xffffffffffff0000 197 - mov ar.pfs=saved_pfs // because of ar.ec, restore no matter what 198 - br.ret.sptk.many rp 199 - END(__strlen_user) 200 - EXPORT_SYMBOL(__strlen_user)
-16
arch/m32r/include/asm/uaccess.h
··· 511 511 */ 512 512 unsigned long clear_user(void __user *mem, unsigned long len); 513 513 514 - /** 515 - * strlen_user: - Get the size of a string in user space. 516 - * @str: The string to measure. 517 - * 518 - * Context: User context only. This function may sleep if pagefaults are 519 - * enabled. 520 - * 521 - * Get the size of a NUL-terminated string in user space. 522 - * 523 - * Returns the size of the string INCLUDING the terminating NUL. 524 - * On exception, returns 0. 525 - * 526 - * If there is a limit on the length of a valid string, you may wish to 527 - * consider using strnlen_user() instead. 528 - */ 529 - #define strlen_user(str) strnlen_user(str, ~0UL >> 1) 530 514 long strnlen_user(const char __user *str, long n); 531 515 532 516 #endif /* _ASM_M32R_UACCESS_H */
-1
arch/m68k/include/asm/uaccess_mm.h
··· 378 378 (uaccess_kernel() ? ~0UL : TASK_SIZE) 379 379 380 380 extern long strncpy_from_user(char *dst, const char __user *src, long count); 381 - extern __must_check long strlen_user(const char __user *str); 382 381 extern __must_check long strnlen_user(const char __user *str, long n); 383 382 384 383 unsigned long __clear_user(void __user *to, unsigned long n);
-2
arch/m68k/include/asm/uaccess_no.h
··· 141 141 return(strlen(src) + 1); /* DAVIDM make safer */ 142 142 } 143 143 144 - #define strlen_user(str) strnlen_user(str, 32767) 145 - 146 144 /* 147 145 * Zero Userspace 148 146 */
-2
arch/metag/include/asm/uaccess.h
··· 188 188 */ 189 189 extern long __must_check strnlen_user(const char __user *src, long count); 190 190 191 - #define strlen_user(str) strnlen_user(str, 32767) 192 - 193 191 extern unsigned long raw_copy_from_user(void *to, const void __user *from, 194 192 unsigned long n); 195 193 extern unsigned long raw_copy_to_user(void __user *to, const void *from,
-44
arch/mips/include/asm/uaccess.h
··· 1073 1073 return res; 1074 1074 } 1075 1075 1076 - extern long __strlen_kernel_asm(const char __user *s); 1077 - extern long __strlen_user_asm(const char __user *s); 1078 - 1079 - /* 1080 - * strlen_user: - Get the size of a string in user space. 1081 - * @str: The string to measure. 1082 - * 1083 - * Context: User context only. This function may sleep if pagefaults are 1084 - * enabled. 1085 - * 1086 - * Get the size of a NUL-terminated string in user space. 1087 - * 1088 - * Returns the size of the string INCLUDING the terminating NUL. 1089 - * On exception, returns 0. 1090 - * 1091 - * If there is a limit on the length of a valid string, you may wish to 1092 - * consider using strnlen_user() instead. 1093 - */ 1094 - static inline long strlen_user(const char __user *s) 1095 - { 1096 - long res; 1097 - 1098 - if (eva_kernel_access()) { 1099 - __asm__ __volatile__( 1100 - "move\t$4, %1\n\t" 1101 - __MODULE_JAL(__strlen_kernel_asm) 1102 - "move\t%0, $2" 1103 - : "=r" (res) 1104 - : "r" (s) 1105 - : "$2", "$4", __UA_t0, "$31"); 1106 - } else { 1107 - might_fault(); 1108 - __asm__ __volatile__( 1109 - "move\t$4, %1\n\t" 1110 - __MODULE_JAL(__strlen_user_asm) 1111 - "move\t%0, $2" 1112 - : "=r" (res) 1113 - : "r" (s) 1114 - : "$2", "$4", __UA_t0, "$31"); 1115 - } 1116 - 1117 - return res; 1118 - } 1119 - 1120 1076 extern long __strnlen_kernel_nocheck_asm(const char __user *s, long n); 1121 1077 extern long __strnlen_user_nocheck_asm(const char __user *s, long n); 1122 1078
+1 -1
arch/mips/lib/Makefile
··· 3 3 # 4 4 5 5 lib-y += bitops.o csum_partial.o delay.o memcpy.o memset.o \ 6 - mips-atomic.o strlen_user.o strncpy_user.o \ 6 + mips-atomic.o strncpy_user.o \ 7 7 strnlen_user.o uncached.o 8 8 9 9 obj-y += iomap.o
-65
arch/mips/lib/strlen_user.S
··· 1 - /* 2 - * This file is subject to the terms and conditions of the GNU General Public 3 - * License. See the file "COPYING" in the main directory of this archive 4 - * for more details. 5 - * 6 - * Copyright (C) 1996, 1998, 1999, 2004 by Ralf Baechle 7 - * Copyright (C) 1999 Silicon Graphics, Inc. 8 - * Copyright (C) 2011 MIPS Technologies, Inc. 9 - */ 10 - #include <asm/asm.h> 11 - #include <asm/asm-offsets.h> 12 - #include <asm/export.h> 13 - #include <asm/regdef.h> 14 - 15 - #define EX(insn,reg,addr,handler) \ 16 - 9: insn reg, addr; \ 17 - .section __ex_table,"a"; \ 18 - PTR 9b, handler; \ 19 - .previous 20 - 21 - /* 22 - * Return the size of a string (including the ending 0) 23 - * 24 - * Return 0 for error 25 - */ 26 - .macro __BUILD_STRLEN_ASM func 27 - LEAF(__strlen_\func\()_asm) 28 - LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok? 29 - and v0, a0 30 - bnez v0, .Lfault\@ 31 - 32 - move v0, a0 33 - .ifeqs "\func", "kernel" 34 - 1: EX(lbu, v1, (v0), .Lfault\@) 35 - .else 36 - 1: EX(lbue, v1, (v0), .Lfault\@) 37 - .endif 38 - PTR_ADDIU v0, 1 39 - bnez v1, 1b 40 - PTR_SUBU v0, a0 41 - jr ra 42 - END(__strlen_\func\()_asm) 43 - 44 - .Lfault\@: move v0, zero 45 - jr ra 46 - .endm 47 - 48 - #ifndef CONFIG_EVA 49 - /* Set aliases */ 50 - .global __strlen_user_asm 51 - .set __strlen_user_asm, __strlen_kernel_asm 52 - EXPORT_SYMBOL(__strlen_user_asm) 53 - #endif 54 - 55 - __BUILD_STRLEN_ASM kernel 56 - EXPORT_SYMBOL(__strlen_kernel_asm) 57 - 58 - #ifdef CONFIG_EVA 59 - 60 - .set push 61 - .set eva 62 - __BUILD_STRLEN_ASM user 63 - .set pop 64 - EXPORT_SYMBOL(__strlen_user_asm) 65 - #endif
-1
arch/mn10300/include/asm/uaccess.h
··· 292 292 extern long strncpy_from_user(char *dst, const char __user *src, long count); 293 293 extern long __strncpy_from_user(char *dst, const char __user *src, long count); 294 294 extern long strnlen_user(const char __user *str, long n); 295 - #define strlen_user(str) strnlen_user(str, ~0UL >> 1) 296 295 extern unsigned long clear_user(void __user *mem, unsigned long len); 297 296 extern unsigned long __clear_user(void __user *mem, unsigned long len); 298 297
-1
arch/openrisc/include/asm/uaccess.h
··· 264 264 265 265 extern long strncpy_from_user(char *dest, const char __user *src, long count); 266 266 267 - extern __must_check long strlen_user(const char __user *str); 268 267 extern __must_check long strnlen_user(const char __user *str, long n); 269 268 270 269 #endif /* __ASM_OPENRISC_UACCESS_H */
-1
arch/parisc/include/asm/uaccess.h
··· 220 220 #define user_addr_max() (~0UL) 221 221 222 222 #define strnlen_user lstrnlen_user 223 - #define strlen_user(str) lstrnlen_user(str, 0x7fffffffL) 224 223 #define clear_user lclear_user 225 224 #define __clear_user lclear_user 226 225
-1
arch/powerpc/include/asm/uaccess.h
··· 346 346 } 347 347 348 348 extern long strncpy_from_user(char *dst, const char __user *src, long count); 349 - extern __must_check long strlen_user(const char __user *str); 350 349 extern __must_check long strnlen_user(const char __user *str, long n); 351 350 352 351 #endif /* _ARCH_POWERPC_UACCESS_H */
-17
arch/s390/include/asm/uaccess.h
··· 276 276 return __strnlen_user(src, n); 277 277 } 278 278 279 - /** 280 - * strlen_user: - Get the size of a string in user space. 281 - * @str: The string to measure. 282 - * 283 - * Context: User context only. This function may sleep if pagefaults are 284 - * enabled. 285 - * 286 - * Get the size of a NUL-terminated string in user space. 287 - * 288 - * Returns the size of the string INCLUDING the terminating NUL. 289 - * On exception, returns 0. 290 - * 291 - * If there is a limit on the length of a valid string, you may wish to 292 - * consider using strnlen_user() instead. 293 - */ 294 - #define strlen_user(str) strnlen_user(str, ~0UL) 295 - 296 279 /* 297 280 * Zero Userspace 298 281 */
-6
arch/score/include/asm/uaccess.h
··· 359 359 return -EFAULT; 360 360 } 361 361 362 - extern int __strlen_user(const char *src); 363 - static inline long strlen_user(const char __user *src) 364 - { 365 - return __strlen_user(src); 366 - } 367 - 368 362 extern int __strnlen_user(const char *str, long len); 369 363 static inline long strnlen_user(const char __user *str, long len) 370 364 {
-28
arch/score/lib/string.S
··· 104 104 .previous 105 105 106 106 .align 2 107 - ENTRY(__strlen_user) 108 - 0: lb r6, [r4] 109 - mv r7, r4 110 - extsb r6, r6 111 - cmpi.c r6, 0 112 - mv r4, r6 113 - beq .L27 114 - .L28: 115 - 1: lb r6, [r7, 1]+ 116 - addi r6, 1 117 - cmpi.c r6, 0 118 - bne .L28 119 - .L27: 120 - br r3 121 - .section .fixup, "ax" 122 - ldi r4, 0x0 123 - br r3 124 - 99: 125 - ldi r4, 0 126 - br r3 127 - .previous 128 - .section __ex_table, "a" 129 - .align 2 130 - .word 0b ,99b 131 - .word 1b ,99b 132 - .previous 133 - 134 - .align 2 135 107 ENTRY(__copy_tofrom_user) 136 108 cmpi.c r6, 0 137 109 mv r10,r6
-1
arch/sh/include/asm/uaccess.h
··· 100 100 101 101 extern long strncpy_from_user(char *dest, const char __user *src, long count); 102 102 103 - extern __must_check long strlen_user(const char __user *str); 104 103 extern __must_check long strnlen_user(const char __user *str, long n); 105 104 106 105 /* Generic arbitrary sized copy. */
-1
arch/sparc/include/asm/uaccess_32.h
··· 277 277 return n; 278 278 } 279 279 280 - __must_check long strlen_user(const char __user *str); 281 280 __must_check long strnlen_user(const char __user *str, long n); 282 281 283 282 #endif /* _ASM_UACCESS_H */
-1
arch/sparc/include/asm/uaccess_64.h
··· 194 194 195 195 #define clear_user __clear_user 196 196 197 - __must_check long strlen_user(const char __user *str); 198 197 __must_check long strnlen_user(const char __user *str, long n); 199 198 200 199 struct pt_regs;
-1
arch/tile/include/asm/uaccess.h
··· 327 327 328 328 329 329 extern long strnlen_user(const char __user *str, long n); 330 - extern long strlen_user(const char __user *str); 331 330 extern long strncpy_from_user(char *dst, const char __user *src, long); 332 331 333 332 /**
-5
arch/um/kernel/process.c
··· 255 255 return clear_user(buf, size); 256 256 } 257 257 258 - int strlen_user_proc(char __user *str) 259 - { 260 - return strlen_user(str); 261 - } 262 - 263 258 int cpu(void) 264 259 { 265 260 return current_thread_info()->cpu;
-1
arch/x86/include/asm/uaccess.h
··· 565 565 extern __must_check long 566 566 strncpy_from_user(char *dst, const char __user *src, long count); 567 567 568 - extern __must_check long strlen_user(const char __user *str); 569 568 extern __must_check long strnlen_user(const char __user *str, long n); 570 569 571 570 unsigned long __must_check clear_user(void __user *mem, unsigned long len);
-3
arch/xtensa/include/asm/uaccess.h
··· 288 288 return -EFAULT; 289 289 } 290 290 291 - 292 - #define strlen_user(str) strnlen_user((str), TASK_SIZE - 1) 293 - 294 291 /* 295 292 * Return the size of a string (including the ending 0!) 296 293 */
-5
include/asm-generic/uaccess.h
··· 200 200 return __strnlen_user(src, n); 201 201 } 202 202 203 - static inline long strlen_user(const char __user *src) 204 - { 205 - return strnlen_user(src, 32767); 206 - } 207 - 208 203 /* 209 204 * Zero Userspace 210 205 */
-34
lib/strnlen_user.c
··· 121 121 return 0; 122 122 } 123 123 EXPORT_SYMBOL(strnlen_user); 124 - 125 - /** 126 - * strlen_user: - Get the size of a user string INCLUDING final NUL. 127 - * @str: The string to measure. 128 - * 129 - * Context: User context only. This function may sleep if pagefaults are 130 - * enabled. 131 - * 132 - * Get the size of a NUL-terminated string in user space. 133 - * 134 - * Returns the size of the string INCLUDING the terminating NUL. 135 - * On exception, returns 0. 136 - * 137 - * If there is a limit on the length of a valid string, you may wish to 138 - * consider using strnlen_user() instead. 139 - */ 140 - long strlen_user(const char __user *str) 141 - { 142 - unsigned long max_addr, src_addr; 143 - 144 - max_addr = user_addr_max(); 145 - src_addr = (unsigned long)str; 146 - if (likely(src_addr < max_addr)) { 147 - unsigned long max = max_addr - src_addr; 148 - long retval; 149 - 150 - user_access_begin(); 151 - retval = do_strnlen_user(str, ~0ul, max); 152 - user_access_end(); 153 - return retval; 154 - } 155 - return 0; 156 - } 157 - EXPORT_SYMBOL(strlen_user);