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

lib/strn*,objtool: Enforce user_access_begin() rules

Apparently GCC can fail to inline a 'static inline' single caller
function:

lib/strnlen_user.o: warning: objtool: strnlen_user()+0x33: call to do_strnlen_user() with UACCESS enabled
lib/strncpy_from_user.o: warning: objtool: strncpy_from_user()+0x33: call to do_strncpy_from_user() with UACCESS enabled

Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220408094718.262932488@infradead.org

+2 -2
+1 -1
lib/strncpy_from_user.c
··· 25 25 * hit it), 'max' is the address space maximum (and we return 26 26 * -EFAULT if we hit it). 27 27 */ 28 - static inline long do_strncpy_from_user(char *dst, const char __user *src, 28 + static __always_inline long do_strncpy_from_user(char *dst, const char __user *src, 29 29 unsigned long count, unsigned long max) 30 30 { 31 31 const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
+1 -1
lib/strnlen_user.c
··· 20 20 * if it fits in a aligned 'long'. The caller needs to check 21 21 * the return value against "> max". 22 22 */ 23 - static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max) 23 + static __always_inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max) 24 24 { 25 25 const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS; 26 26 unsigned long align, res = 0;