Re: [PATCH v5 04/44] x86: asm: instrument usercopy in get_user() and put_user()

From: Christophe Leroy
Date: Tue Aug 30 2022 - 11:06:33 EST




Le 26/08/2022 à 17:07, Alexander Potapenko a écrit :
> 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 <glider@xxxxxxxxxx>
> ---
> v5:
> -- handle put_user(), make sure to not evaluate pointer/value twice
>
> Link: https://linux-review.googlesource.com/id/Ia9f12bfe5832623250e20f1859fdf5cc485a2fce
> ---
> arch/x86/include/asm/uaccess.h | 22 +++++++++++++++-------
> 1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
> index 913e593a3b45f..c1b8982899eca 100644
> --- a/arch/x86/include/asm/uaccess.h
> +++ b/arch/x86/include/asm/uaccess.h
> @@ -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); \

Where is that instrument_get_user() defined ? I can't find it neither in
v6.0-rc3 nor in linux-next.

> (x) = (__force __typeof__(*(ptr))) __val_gu; \
> __builtin_expect(__ret_gu, 0); \
> })

Christophe