x86-asm-instrument-usercopy-in-get_user-and-put_user.patch removed from -mm tree
The quilt patch titled
Subject: x86: asm: instrument usercopy in get_user() and put_user()
has been removed from the -mm tree. Its filename was
x86-asm-instrument-usercopy-in-get_user-and-put_user.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Alexander Potapenko <[email protected]>
Subject: x86: asm: instrument usercopy in get_user() and put_user()
Date: Thu, 15 Sep 2022 17:03:38 +0200
Use hooks from instrumented.h to notify bug detection tools about usercopy events in variations of get_user() and put_user().
Signed-off-by Alexander Potapenko <[email protected]>
Cc Alexander Viro <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Andrey Konovalov <[email protected]>
Cc Andrey Konovalov <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc David Rientjes <[email protected]>
Cc Dmitry Vyukov <[email protected]>
Cc Eric Biggers <[email protected]>
Cc Eric Biggers <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Herbert Xu <[email protected]>
Cc Ilya Leoshkevich <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Kees Cook <[email protected]>
Cc Marco Elver <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Pekka Enberg <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Stephen Rothwell <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Vegard Nossum <[email protected]>
Cc Vlastimil Babka <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
arch/x86/include/asm/uaccess.h | 22 +++++++++++++++------- include/linux/instrumented.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 7 deletions(-)
arch/x86/include/asm/uaccess.h renamed from arch/x86/include/asm/uaccess.h~x86-asm-instrument-usercopy-in-get_user-and-put_user +15 -7
@@ -5,6 +5,7 @@* User space memory access functions */ #include <linux/compiler.h> +#include <linux/instrumented.h> #include <linux/kasan-checks.h> #include <linux/string.h> #include <asm/asm.h>
@@ -103,6 +104,7 @@ extern int __get_user_bad(void); : "=a" (__ret_gu), "=r" (__val_gu), \ ASM_CALL_CONSTRAINT \ : "0" (ptr), "i" (sizeof(*(ptr)))); \ +instrument_get_user (__val_gu); \ (x) = (__force __typeof__(*(ptr))) __val_gu; \__builtin_expect (__ret_gu,0 ); \ })
@@ -192,9 +194,11 @@ extern void __put_user_nocheck_8(void);int __ret_pu; \ void __user *__ptr_pu; \ register __typeof__(*(ptr)) __val_pu asm("%"_ASM_AX); \ -__chk_user_ptr (ptr); \ - __ptr_pu = (ptr); \ - __val_pu = (x); \ + __typeof__(*(ptr)) __x = (x); /* eval x once */ \ +__typeof__ (ptr) __ptr = (ptr);/* eval ptr once */ \ +__chk_user_ptr (__ptr); \ + __ptr_pu = __ptr; \ + __val_pu = __x; \ asm volatile("call __" #fn "_%P[size]" \ : "=c" (__ret_pu), \ ASM_CALL_CONSTRAINT \
@@ -202,6 +206,7 @@ extern void __put_user_nocheck_8(void); "r" (__val_pu), \ [size] "i" (sizeof(*(ptr))) \:" ebx"); \ +instrument_put_user(__x, __ptr, sizeof(*(ptr))); \ __builtin_expect(__ret_pu, 0); \ })
@@ -248,23 +253,25 @@ extern void __put_user_nocheck_8(void);#define __put_user_size (x, ptr, size, label) \ do { \ + __typeof__(*(ptr)) __x = (x);/* eval x once */ \__chk_user_ptr (ptr); \switch (size) { \case 1 : \ - __put_user_goto(x, ptr, "b", "iq", label); \ +__put_user_goto (__x, ptr,"b" ,"iq" , label); \break ; \case 2 : \ - __put_user_goto(x, ptr, "w", "ir", label); \ +__put_user_goto (__x, ptr,"w" ,"ir" , label); \break ; \case 4 : \ - __put_user_goto(x, ptr, "l", "ir", label); \ +__put_user_goto (__x, ptr,"l" ,"ir" , label); \break ; \case 8 : \ - __put_user_goto_u64(x, ptr, label); \ +__put_user_goto_u64 (__x, ptr, label); \break ; \default : \__put_user_bad (); \ } \ +instrument_put_user (__x, ptr, size); \ }while (0 ) #ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT
@@ -305,6 +312,7 @@ do { \default : \ (x) =__get_user_bad (); \ } \ +instrument_get_user (x); \ }while (0 ) #define __get_user_asm(x, addr, itype, ltype, label) \
include/linux/instrumented.h renamed from include/linux/instrumented.h~x86-asm-instrument-usercopy-in-get_user-and-put_user +28 -0
@@ -153,4 +153,32 @@ instrument_copy_from_user_after(const vo { } +/** +* instrument_get_user() - add instrumentation to get_user()-like macros +* +* get_user() and friends are fragile, so it may depend on the implementation +* whether the instrumentation happens before or after the data is copied from +* the userspace. +* +* @to destination variable, may not be address-taken +*/ +#define instrument_get_user (to) \ +({ \ +}) + +/** +* instrument_put_user() - add instrumentation to put_user()-like macros +* +* put_user() and friends are fragile, so it may depend on the implementation +* whether the instrumentation happens before or after the data is copied from +* the userspace. +* +* @from source address +* @ptr userspace pointer to copy to +* @size number of bytes to copy +*/ +#define instrument_put_user (from, ptr, size) \ +({ \ +}) +#endif /* _LINUX_INSTRUMENTED_H */
_
Patches currently in -mm which might be from [email protected] are