From: Patrick Farrell Date: Tue, 18 Apr 2023 06:12:53 +0000 (-0700) Subject: LU-16510 build: include unsafe_memcpy definition X-Git-Tag: 2.15.3-RC1~25 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=8f4004809461bb2cab20c72d20980edf32c98793;p=fs%2Flustre-release.git LU-16510 build: include unsafe_memcpy definition The original LU-16510 missed a key part of the unsafe_memcpy code from the upstream kernel, and so we weren't actually defining unsafe_memcpy() as intended. Thanks to Aurelien Degremont for pointing this out. Lustre-change: https://review.whamcloud.com/50573 Lustre-commit: 565b21bf65e385a9b4fd8ee31cabe7892345b783 Fixes: 919b93b9 ("LU-16510 build: fortified memcpy from linux 6.1") Signed-off-by: Patrick Farrell Change-Id: Ib9e2d56ed0b3691f1ab9fcd25403fa86ac784b6d Reviewed-by: Andreas Dilger Reviewed-by: Aurelien Degremont Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50667 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/libcfs/include/libcfs/linux/linux-fortify-string.h b/libcfs/include/libcfs/linux/linux-fortify-string.h index bf03e0e..aeed8c5 100644 --- a/libcfs/include/libcfs/linux/linux-fortify-string.h +++ b/libcfs/include/libcfs/linux/linux-fortify-string.h @@ -80,6 +80,22 @@ extern char *__underlying_strncpy(char *p, const char *q, __kernel_size_t size) #define __underlying_strncpy __builtin_strncpy #endif +/** + * unsafe_memcpy - memcpy implementation with no FORTIFY bounds checking + * + * @dst: Destination memory address to write to + * @src: Source memory address to read from + * @bytes: How many bytes to write to @dst from @src + * @justification: Free-form text or comment describing why the use is needed + * + * This should be used for corner cases where the compiler cannot do the + * right thing, or during transitions between APIs, etc. It should be used + * very rarely, and includes a place for justification detailing where bounds + * checking has happened, and why existing solutions cannot be employed. + */ +#define unsafe_memcpy(dst, src, bytes, justification) \ + __underlying_memcpy(dst, src, bytes) + /* * Clang's use of __builtin_*object_size() within inlines needs hinting via * __pass_*object_size(). The preference is to only ever use type 1 (member