1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _LINUX_FORTIFY_STRING_H_ 3 #define _LINUX_FORTIFY_STRING_H_ 4 5 #include <linux/bug.h> 6 #include <linux/const.h> 7 #include <linux/limits.h> 8 9 #define __FORTIFY_INLINE extern __always_inline __gnu_inline __overloadable 10 #define __RENAME(x) __asm__(#x) 11 12 void fortify_panic(const char *name) __noreturn __cold; 13 void __read_overflow(void) __compiletime_error("detected read beyond size of object (1st parameter)"); 14 void __read_overflow2(void) __compiletime_error("detected read beyond size of object (2nd parameter)"); 15 void __read_overflow2_field(size_t avail, size_t wanted) __compiletime_warning("detected read beyond size of field (2nd parameter); maybe use struct_group()?"); 16 void __write_overflow(void) __compiletime_error("detected write beyond size of object (1st parameter)"); 17 void __write_overflow_field(size_t avail, size_t wanted) __compiletime_warning("detected write beyond size of field (1st parameter); maybe use struct_group()?"); 18 19 #define __compiletime_strlen(p) \ 20 ({ \ 21 unsigned char *__p = (unsigned char *)(p); \ 22 size_t __ret = SIZE_MAX; \ 23 size_t __p_size = __member_size(p); \ 24 if (__p_size != SIZE_MAX && \ 25 __builtin_constant_p(*__p)) { \ 26 size_t __p_len = __p_size - 1; \ 27 if (__builtin_constant_p(__p[__p_len]) && \ 28 __p[__p_len] == '\0') \ 29 __ret = __builtin_strlen(__p); \ 30 } \ 31 __ret; \ 32 }) 33 34 #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) 35 extern void *__underlying_memchr(const void *p, int c, __kernel_size_t size) __RENAME(memchr); 36 extern int __underlying_memcmp(const void *p, const void *q, __kernel_size_t size) __RENAME(memcmp); 37 extern void *__underlying_memcpy(void *p, const void *q, __kernel_size_t size) __RENAME(memcpy); 38 extern void *__underlying_memmove(void *p, const void *q, __kernel_size_t size) __RENAME(memmove); 39 extern void *__underlying_memset(void *p, int c, __kernel_size_t size) __RENAME(memset); 40 extern char *__underlying_strcat(char *p, const char *q) __RENAME(strcat); 41 extern char *__underlying_strcpy(char *p, const char *q) __RENAME(strcpy); 42 extern __kernel_size_t __underlying_strlen(const char *p) __RENAME(strlen); 43 extern char *__underlying_strncat(char *p, const char *q, __kernel_size_t count) __RENAME(strncat); 44 extern char *__underlying_strncpy(char *p, const char *q, __kernel_size_t size) __RENAME(strncpy); 45 #else 46 47 #if defined(__SANITIZE_MEMORY__) 48 /* 49 * For KMSAN builds all memcpy/memset/memmove calls should be replaced by the 50 * corresponding __msan_XXX functions. 51 */ 52 #include <linux/kmsan_string.h> 53 #define __underlying_memcpy __msan_memcpy 54 #define __underlying_memmove __msan_memmove 55 #define __underlying_memset __msan_memset 56 #else 57 #define __underlying_memcpy __builtin_memcpy 58 #define __underlying_memmove __builtin_memmove 59 #define __underlying_memset __builtin_memset 60 #endif 61 62 #define __underlying_memchr __builtin_memchr 63 #define __underlying_memcmp __builtin_memcmp 64 #define __underlying_strcat __builtin_strcat 65 #define __underlying_strcpy __builtin_strcpy 66 #define __underlying_strlen __builtin_strlen 67 #define __underlying_strncat __builtin_strncat 68 #define __underlying_strncpy __builtin_strncpy 69 #endif 70 71 /** 72 * unsafe_memcpy - memcpy implementation with no FORTIFY bounds checking 73 * 74 * @dst: Destination memory address to write to 75 * @src: Source memory address to read from 76 * @bytes: How many bytes to write to @dst from @src 77 * @justification: Free-form text or comment describing why the use is needed 78 * 79 * This should be used for corner cases where the compiler cannot do the 80 * right thing, or during transitions between APIs, etc. It should be used 81 * very rarely, and includes a place for justification detailing where bounds 82 * checking has happened, and why existing solutions cannot be employed. 83 */ 84 #define unsafe_memcpy(dst, src, bytes, justification) \ 85 __underlying_memcpy(dst, src, bytes) 86 87 /* 88 * Clang's use of __builtin_*object_size() within inlines needs hinting via 89 * __pass_*object_size(). The preference is to only ever use type 1 (member 90 * size, rather than struct size), but there remain some stragglers using 91 * type 0 that will be converted in the future. 92 */ 93 #define POS __pass_object_size(1) 94 #define POS0 __pass_object_size(0) 95 #define __struct_size(p) __builtin_object_size(p, 0) 96 #define __member_size(p) __builtin_object_size(p, 1) 97 98 #define __compiletime_lessthan(bounds, length) ( \ 99 __builtin_constant_p((bounds) < (length)) && \ 100 (bounds) < (length) \ 101 ) 102 103 /** 104 * strncpy - Copy a string to memory with non-guaranteed NUL padding 105 * 106 * @p: pointer to destination of copy 107 * @q: pointer to NUL-terminated source string to copy 108 * @size: bytes to write at @p 109 * 110 * If strlen(@q) >= @size, the copy of @q will stop after @size bytes, 111 * and @p will NOT be NUL-terminated 112 * 113 * If strlen(@q) < @size, following the copy of @q, trailing NUL bytes 114 * will be written to @p until @size total bytes have been written. 115 * 116 * Do not use this function. While FORTIFY_SOURCE tries to avoid 117 * over-reads of @q, it cannot defend against writing unterminated 118 * results to @p. Using strncpy() remains ambiguous and fragile. 119 * Instead, please choose an alternative, so that the expectation 120 * of @p's contents is unambiguous: 121 * 122 * +--------------------+-----------------+------------+ 123 * | @p needs to be: | padded to @size | not padded | 124 * +====================+=================+============+ 125 * | NUL-terminated | strscpy_pad() | strscpy() | 126 * +--------------------+-----------------+------------+ 127 * | not NUL-terminated | strtomem_pad() | strtomem() | 128 * +--------------------+-----------------+------------+ 129 * 130 * Note strscpy*()'s differing return values for detecting truncation, 131 * and strtomem*()'s expectation that the destination is marked with 132 * __nonstring when it is a character array. 133 * 134 */ 135 __FORTIFY_INLINE __diagnose_as(__builtin_strncpy, 1, 2, 3) 136 char *strncpy(char * const POS p, const char *q, __kernel_size_t size) 137 { 138 size_t p_size = __member_size(p); 139 140 if (__compiletime_lessthan(p_size, size)) 141 __write_overflow(); 142 if (p_size < size) 143 fortify_panic(__func__); 144 return __underlying_strncpy(p, q, size); 145 } 146 147 __FORTIFY_INLINE __diagnose_as(__builtin_strcat, 1, 2) 148 char *strcat(char * const POS p, const char *q) 149 { 150 size_t p_size = __member_size(p); 151 152 if (p_size == SIZE_MAX) 153 return __underlying_strcat(p, q); 154 if (strlcat(p, q, p_size) >= p_size) 155 fortify_panic(__func__); 156 return p; 157 } 158 159 extern __kernel_size_t __real_strnlen(const char *, __kernel_size_t) __RENAME(strnlen); 160 __FORTIFY_INLINE __kernel_size_t strnlen(const char * const POS p, __kernel_size_t maxlen) 161 { 162 size_t p_size = __member_size(p); 163 size_t p_len = __compiletime_strlen(p); 164 size_t ret; 165 166 /* We can take compile-time actions when maxlen is const. */ 167 if (__builtin_constant_p(maxlen) && p_len != SIZE_MAX) { 168 /* If p is const, we can use its compile-time-known len. */ 169 if (maxlen >= p_size) 170 return p_len; 171 } 172 173 /* Do not check characters beyond the end of p. */ 174 ret = __real_strnlen(p, maxlen < p_size ? maxlen : p_size); 175 if (p_size <= ret && maxlen != ret) 176 fortify_panic(__func__); 177 return ret; 178 } 179 180 /* 181 * Defined after fortified strnlen to reuse it. However, it must still be 182 * possible for strlen() to be used on compile-time strings for use in 183 * static initializers (i.e. as a constant expression). 184 */ 185 #define strlen(p) \ 186 __builtin_choose_expr(__is_constexpr(__builtin_strlen(p)), \ 187 __builtin_strlen(p), __fortify_strlen(p)) 188 __FORTIFY_INLINE __diagnose_as(__builtin_strlen, 1) 189 __kernel_size_t __fortify_strlen(const char * const POS p) 190 { 191 __kernel_size_t ret; 192 size_t p_size = __member_size(p); 193 194 /* Give up if we don't know how large p is. */ 195 if (p_size == SIZE_MAX) 196 return __underlying_strlen(p); 197 ret = strnlen(p, p_size); 198 if (p_size <= ret) 199 fortify_panic(__func__); 200 return ret; 201 } 202 203 /* defined after fortified strlen to reuse it */ 204 extern size_t __real_strlcpy(char *, const char *, size_t) __RENAME(strlcpy); 205 __FORTIFY_INLINE size_t strlcpy(char * const POS p, const char * const POS q, size_t size) 206 { 207 size_t p_size = __member_size(p); 208 size_t q_size = __member_size(q); 209 size_t q_len; /* Full count of source string length. */ 210 size_t len; /* Count of characters going into destination. */ 211 212 if (p_size == SIZE_MAX && q_size == SIZE_MAX) 213 return __real_strlcpy(p, q, size); 214 q_len = strlen(q); 215 len = (q_len >= size) ? size - 1 : q_len; 216 if (__builtin_constant_p(size) && __builtin_constant_p(q_len) && size) { 217 /* Write size is always larger than destination. */ 218 if (len >= p_size) 219 __write_overflow(); 220 } 221 if (size) { 222 if (len >= p_size) 223 fortify_panic(__func__); 224 __underlying_memcpy(p, q, len); 225 p[len] = '\0'; 226 } 227 return q_len; 228 } 229 230 /* defined after fortified strnlen to reuse it */ 231 extern ssize_t __real_strscpy(char *, const char *, size_t) __RENAME(strscpy); 232 __FORTIFY_INLINE ssize_t strscpy(char * const POS p, const char * const POS q, size_t size) 233 { 234 size_t len; 235 /* Use string size rather than possible enclosing struct size. */ 236 size_t p_size = __member_size(p); 237 size_t q_size = __member_size(q); 238 239 /* If we cannot get size of p and q default to call strscpy. */ 240 if (p_size == SIZE_MAX && q_size == SIZE_MAX) 241 return __real_strscpy(p, q, size); 242 243 /* 244 * If size can be known at compile time and is greater than 245 * p_size, generate a compile time write overflow error. 246 */ 247 if (__compiletime_lessthan(p_size, size)) 248 __write_overflow(); 249 250 /* 251 * This call protects from read overflow, because len will default to q 252 * length if it smaller than size. 253 */ 254 len = strnlen(q, size); 255 /* 256 * If len equals size, we will copy only size bytes which leads to 257 * -E2BIG being returned. 258 * Otherwise we will copy len + 1 because of the final '\O'. 259 */ 260 len = len == size ? size : len + 1; 261 262 /* 263 * Generate a runtime write overflow error if len is greater than 264 * p_size. 265 */ 266 if (len > p_size) 267 fortify_panic(__func__); 268 269 /* 270 * We can now safely call vanilla strscpy because we are protected from: 271 * 1. Read overflow thanks to call to strnlen(). 272 * 2. Write overflow thanks to above ifs. 273 */ 274 return __real_strscpy(p, q, len); 275 } 276 277 /* defined after fortified strlen and strnlen to reuse them */ 278 __FORTIFY_INLINE __diagnose_as(__builtin_strncat, 1, 2, 3) 279 char *strncat(char * const POS p, const char * const POS q, __kernel_size_t count) 280 { 281 size_t p_len, copy_len; 282 size_t p_size = __member_size(p); 283 size_t q_size = __member_size(q); 284 285 if (p_size == SIZE_MAX && q_size == SIZE_MAX) 286 return __underlying_strncat(p, q, count); 287 p_len = strlen(p); 288 copy_len = strnlen(q, count); 289 if (p_size < p_len + copy_len + 1) 290 fortify_panic(__func__); 291 __underlying_memcpy(p + p_len, q, copy_len); 292 p[p_len + copy_len] = '\0'; 293 return p; 294 } 295 296 __FORTIFY_INLINE void fortify_memset_chk(__kernel_size_t size, 297 const size_t p_size, 298 const size_t p_size_field) 299 { 300 if (__builtin_constant_p(size)) { 301 /* 302 * Length argument is a constant expression, so we 303 * can perform compile-time bounds checking where 304 * buffer sizes are also known at compile time. 305 */ 306 307 /* Error when size is larger than enclosing struct. */ 308 if (__compiletime_lessthan(p_size_field, p_size) && 309 __compiletime_lessthan(p_size, size)) 310 __write_overflow(); 311 312 /* Warn when write size is larger than dest field. */ 313 if (__compiletime_lessthan(p_size_field, size)) 314 __write_overflow_field(p_size_field, size); 315 } 316 /* 317 * At this point, length argument may not be a constant expression, 318 * so run-time bounds checking can be done where buffer sizes are 319 * known. (This is not an "else" because the above checks may only 320 * be compile-time warnings, and we want to still warn for run-time 321 * overflows.) 322 */ 323 324 /* 325 * Always stop accesses beyond the struct that contains the 326 * field, when the buffer's remaining size is known. 327 * (The SIZE_MAX test is to optimize away checks where the buffer 328 * lengths are unknown.) 329 */ 330 if (p_size != SIZE_MAX && p_size < size) 331 fortify_panic("memset"); 332 } 333 334 #define __fortify_memset_chk(p, c, size, p_size, p_size_field) ({ \ 335 size_t __fortify_size = (size_t)(size); \ 336 fortify_memset_chk(__fortify_size, p_size, p_size_field), \ 337 __underlying_memset(p, c, __fortify_size); \ 338 }) 339 340 /* 341 * __struct_size() vs __member_size() must be captured here to avoid 342 * evaluating argument side-effects further into the macro layers. 343 */ 344 #ifndef CONFIG_KMSAN 345 #define memset(p, c, s) __fortify_memset_chk(p, c, s, \ 346 __struct_size(p), __member_size(p)) 347 #endif 348 349 /* 350 * To make sure the compiler can enforce protection against buffer overflows, 351 * memcpy(), memmove(), and memset() must not be used beyond individual 352 * struct members. If you need to copy across multiple members, please use 353 * struct_group() to create a named mirror of an anonymous struct union. 354 * (e.g. see struct sk_buff.) Read overflow checking is currently only 355 * done when a write overflow is also present, or when building with W=1. 356 * 357 * Mitigation coverage matrix 358 * Bounds checking at: 359 * +-------+-------+-------+-------+ 360 * | Compile time | Run time | 361 * memcpy() argument sizes: | write | read | write | read | 362 * dest source length +-------+-------+-------+-------+ 363 * memcpy(known, known, constant) | y | y | n/a | n/a | 364 * memcpy(known, unknown, constant) | y | n | n/a | V | 365 * memcpy(known, known, dynamic) | n | n | B | B | 366 * memcpy(known, unknown, dynamic) | n | n | B | V | 367 * memcpy(unknown, known, constant) | n | y | V | n/a | 368 * memcpy(unknown, unknown, constant) | n | n | V | V | 369 * memcpy(unknown, known, dynamic) | n | n | V | B | 370 * memcpy(unknown, unknown, dynamic) | n | n | V | V | 371 * +-------+-------+-------+-------+ 372 * 373 * y = perform deterministic compile-time bounds checking 374 * n = cannot perform deterministic compile-time bounds checking 375 * n/a = no run-time bounds checking needed since compile-time deterministic 376 * B = can perform run-time bounds checking (currently unimplemented) 377 * V = vulnerable to run-time overflow (will need refactoring to solve) 378 * 379 */ 380 __FORTIFY_INLINE bool fortify_memcpy_chk(__kernel_size_t size, 381 const size_t p_size, 382 const size_t q_size, 383 const size_t p_size_field, 384 const size_t q_size_field, 385 const char *func) 386 { 387 if (__builtin_constant_p(size)) { 388 /* 389 * Length argument is a constant expression, so we 390 * can perform compile-time bounds checking where 391 * buffer sizes are also known at compile time. 392 */ 393 394 /* Error when size is larger than enclosing struct. */ 395 if (__compiletime_lessthan(p_size_field, p_size) && 396 __compiletime_lessthan(p_size, size)) 397 __write_overflow(); 398 if (__compiletime_lessthan(q_size_field, q_size) && 399 __compiletime_lessthan(q_size, size)) 400 __read_overflow2(); 401 402 /* Warn when write size argument larger than dest field. */ 403 if (__compiletime_lessthan(p_size_field, size)) 404 __write_overflow_field(p_size_field, size); 405 /* 406 * Warn for source field over-read when building with W=1 407 * or when an over-write happened, so both can be fixed at 408 * the same time. 409 */ 410 if ((IS_ENABLED(KBUILD_EXTRA_WARN1) || 411 __compiletime_lessthan(p_size_field, size)) && 412 __compiletime_lessthan(q_size_field, size)) 413 __read_overflow2_field(q_size_field, size); 414 } 415 /* 416 * At this point, length argument may not be a constant expression, 417 * so run-time bounds checking can be done where buffer sizes are 418 * known. (This is not an "else" because the above checks may only 419 * be compile-time warnings, and we want to still warn for run-time 420 * overflows.) 421 */ 422 423 /* 424 * Always stop accesses beyond the struct that contains the 425 * field, when the buffer's remaining size is known. 426 * (The SIZE_MAX test is to optimize away checks where the buffer 427 * lengths are unknown.) 428 */ 429 if ((p_size != SIZE_MAX && p_size < size) || 430 (q_size != SIZE_MAX && q_size < size)) 431 fortify_panic(func); 432 433 /* 434 * Warn when writing beyond destination field size. 435 * 436 * We must ignore p_size_field == 0 for existing 0-element 437 * fake flexible arrays, until they are all converted to 438 * proper flexible arrays. 439 * 440 * The implementation of __builtin_*object_size() behaves 441 * like sizeof() when not directly referencing a flexible 442 * array member, which means there will be many bounds checks 443 * that will appear at run-time, without a way for them to be 444 * detected at compile-time (as can be done when the destination 445 * is specifically the flexible array member). 446 * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101832 447 */ 448 if (p_size_field != 0 && p_size_field != SIZE_MAX && 449 p_size != p_size_field && p_size_field < size) 450 return true; 451 452 return false; 453 } 454 455 #define __fortify_memcpy_chk(p, q, size, p_size, q_size, \ 456 p_size_field, q_size_field, op) ({ \ 457 size_t __fortify_size = (size_t)(size); \ 458 WARN_ONCE(fortify_memcpy_chk(__fortify_size, p_size, q_size, \ 459 p_size_field, q_size_field, #op), \ 460 #op ": detected field-spanning write (size %zu) of single %s (size %zu)\n", \ 461 __fortify_size, \ 462 "field \"" #p "\" at " __FILE__ ":" __stringify(__LINE__), \ 463 p_size_field); \ 464 __underlying_##op(p, q, __fortify_size); \ 465 }) 466 467 /* 468 * Notes about compile-time buffer size detection: 469 * 470 * With these types... 471 * 472 * struct middle { 473 * u16 a; 474 * u8 middle_buf[16]; 475 * int b; 476 * }; 477 * struct end { 478 * u16 a; 479 * u8 end_buf[16]; 480 * }; 481 * struct flex { 482 * int a; 483 * u8 flex_buf[]; 484 * }; 485 * 486 * void func(TYPE *ptr) { ... } 487 * 488 * Cases where destination size cannot be currently detected: 489 * - the size of ptr's object (seemingly by design, gcc & clang fail): 490 * __builtin_object_size(ptr, 1) == SIZE_MAX 491 * - the size of flexible arrays in ptr's obj (by design, dynamic size): 492 * __builtin_object_size(ptr->flex_buf, 1) == SIZE_MAX 493 * - the size of ANY array at the end of ptr's obj (gcc and clang bug): 494 * __builtin_object_size(ptr->end_buf, 1) == SIZE_MAX 495 * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 496 * 497 * Cases where destination size is currently detected: 498 * - the size of non-array members within ptr's object: 499 * __builtin_object_size(ptr->a, 1) == 2 500 * - the size of non-flexible-array in the middle of ptr's obj: 501 * __builtin_object_size(ptr->middle_buf, 1) == 16 502 * 503 */ 504 505 /* 506 * __struct_size() vs __member_size() must be captured here to avoid 507 * evaluating argument side-effects further into the macro layers. 508 */ 509 #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ 510 __struct_size(p), __struct_size(q), \ 511 __member_size(p), __member_size(q), \ 512 memcpy) 513 #define memmove(p, q, s) __fortify_memcpy_chk(p, q, s, \ 514 __struct_size(p), __struct_size(q), \ 515 __member_size(p), __member_size(q), \ 516 memmove) 517 518 extern void *__real_memscan(void *, int, __kernel_size_t) __RENAME(memscan); 519 __FORTIFY_INLINE void *memscan(void * const POS0 p, int c, __kernel_size_t size) 520 { 521 size_t p_size = __struct_size(p); 522 523 if (__compiletime_lessthan(p_size, size)) 524 __read_overflow(); 525 if (p_size < size) 526 fortify_panic(__func__); 527 return __real_memscan(p, c, size); 528 } 529 530 __FORTIFY_INLINE __diagnose_as(__builtin_memcmp, 1, 2, 3) 531 int memcmp(const void * const POS0 p, const void * const POS0 q, __kernel_size_t size) 532 { 533 size_t p_size = __struct_size(p); 534 size_t q_size = __struct_size(q); 535 536 if (__builtin_constant_p(size)) { 537 if (__compiletime_lessthan(p_size, size)) 538 __read_overflow(); 539 if (__compiletime_lessthan(q_size, size)) 540 __read_overflow2(); 541 } 542 if (p_size < size || q_size < size) 543 fortify_panic(__func__); 544 return __underlying_memcmp(p, q, size); 545 } 546 547 __FORTIFY_INLINE __diagnose_as(__builtin_memchr, 1, 2, 3) 548 void *memchr(const void * const POS0 p, int c, __kernel_size_t size) 549 { 550 size_t p_size = __struct_size(p); 551 552 if (__compiletime_lessthan(p_size, size)) 553 __read_overflow(); 554 if (p_size < size) 555 fortify_panic(__func__); 556 return __underlying_memchr(p, c, size); 557 } 558 559 void *__real_memchr_inv(const void *s, int c, size_t n) __RENAME(memchr_inv); 560 __FORTIFY_INLINE void *memchr_inv(const void * const POS0 p, int c, size_t size) 561 { 562 size_t p_size = __struct_size(p); 563 564 if (__compiletime_lessthan(p_size, size)) 565 __read_overflow(); 566 if (p_size < size) 567 fortify_panic(__func__); 568 return __real_memchr_inv(p, c, size); 569 } 570 571 extern void *__real_kmemdup(const void *src, size_t len, gfp_t gfp) __RENAME(kmemdup); 572 __FORTIFY_INLINE void *kmemdup(const void * const POS0 p, size_t size, gfp_t gfp) 573 { 574 size_t p_size = __struct_size(p); 575 576 if (__compiletime_lessthan(p_size, size)) 577 __read_overflow(); 578 if (p_size < size) 579 fortify_panic(__func__); 580 return __real_kmemdup(p, size, gfp); 581 } 582 583 /* Defined after fortified strlen to reuse it. */ 584 __FORTIFY_INLINE __diagnose_as(__builtin_strcpy, 1, 2) 585 char *strcpy(char * const POS p, const char * const POS q) 586 { 587 size_t p_size = __member_size(p); 588 size_t q_size = __member_size(q); 589 size_t size; 590 591 /* If neither buffer size is known, immediately give up. */ 592 if (__builtin_constant_p(p_size) && 593 __builtin_constant_p(q_size) && 594 p_size == SIZE_MAX && q_size == SIZE_MAX) 595 return __underlying_strcpy(p, q); 596 size = strlen(q) + 1; 597 /* Compile-time check for const size overflow. */ 598 if (__compiletime_lessthan(p_size, size)) 599 __write_overflow(); 600 /* Run-time check for dynamic size overflow. */ 601 if (p_size < size) 602 fortify_panic(__func__); 603 __underlying_memcpy(p, q, size); 604 return p; 605 } 606 607 /* Don't use these outside the FORITFY_SOURCE implementation */ 608 #undef __underlying_memchr 609 #undef __underlying_memcmp 610 #undef __underlying_strcat 611 #undef __underlying_strcpy 612 #undef __underlying_strlen 613 #undef __underlying_strncat 614 #undef __underlying_strncpy 615 616 #undef POS 617 #undef POS0 618 619 #endif /* _LINUX_FORTIFY_STRING_H_ */ 620