[3/4] objdump: add UACCESS exception for more stringops

Message ID 20230208164011.2287122-3-arnd@kernel.org
State New
Headers
Series [1/4] kasan: mark addr_has_metadata __always_inline |

Commit Message

Arnd Bergmann Feb. 8, 2023, 4:39 p.m. UTC
  From: Arnd Bergmann <arnd@arndb.de>

The memset/memmove/memcpy string functions are wrapped in different
ways based on configuration. While the __asan_mem* functions already
have exceptions, the ones called from those do not:

mm/kasan/shadow.o: warning: objtool: __asan_memset+0x30: call to __memset() with UACCESS enabled
mm/kasan/shadow.o: warning: objtool: __asan_memmove+0x51: call to __memmove() with UACCESS enabled
mm/kasan/shadow.o: warning: objtool: __asan_memcpy+0x51: call to __memcpy() with UACCESS enabled
vmlinux.o: warning: objtool: .altinstr_replacement+0x1406: call to memcpy_erms() with UACCESS enabled
vmlinux.o: warning: objtool: .altinstr_replacement+0xed0: call to memset_erms() with UACCESS enabled
vmlinux.o: warning: objtool: memset+0x4: call to memset_orig() with UACCESS enabled
vmlinux.o: warning: objtool: memset+0x4: call to memset_orig() with UACCESS enabled

Add these to the list as well.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 tools/objtool/check.c | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Peter Zijlstra Feb. 8, 2023, 6:09 p.m. UTC | #1
On Wed, Feb 08, 2023 at 05:39:57PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The memset/memmove/memcpy string functions are wrapped in different
> ways based on configuration. While the __asan_mem* functions already
> have exceptions, the ones called from those do not:
> 
> mm/kasan/shadow.o: warning: objtool: __asan_memset+0x30: call to __memset() with UACCESS enabled
> mm/kasan/shadow.o: warning: objtool: __asan_memmove+0x51: call to __memmove() with UACCESS enabled
> mm/kasan/shadow.o: warning: objtool: __asan_memcpy+0x51: call to __memcpy() with UACCESS enabled
> vmlinux.o: warning: objtool: .altinstr_replacement+0x1406: call to memcpy_erms() with UACCESS enabled
> vmlinux.o: warning: objtool: .altinstr_replacement+0xed0: call to memset_erms() with UACCESS enabled
> vmlinux.o: warning: objtool: memset+0x4: call to memset_orig() with UACCESS enabled
> vmlinux.o: warning: objtool: memset+0x4: call to memset_orig() with UACCESS enabled
> 
> Add these to the list as well.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  tools/objtool/check.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 0f67c6a8bc98..e8fb3bf7a2e3 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -1248,6 +1248,13 @@ static const char *uaccess_safe_builtin[] = {
>  	"clear_user_erms",
>  	"clear_user_rep_good",
>  	"clear_user_original",
> +	"__memset",
> +	"__memcpy",
> +	"__memmove",
> +	"memset_erms",
> +	"memcpy_erms",
> +	"memset_orig",
> +	"memcpy_orig",
>  	NULL
>  };

Hmm, I wanted to go the other way and remove __asan_mem*.

  https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/commit/?h=sched/core-robot&id=79cdfdacd5b8d1ac77e24ccbc178bba0294d0d78
  
Arnd Bergmann Feb. 8, 2023, 7:27 p.m. UTC | #2
On Wed, Feb 8, 2023, at 19:09, Peter Zijlstra wrote:
> On Wed, Feb 08, 2023 at 05:39:57PM +0100, Arnd Bergmann wrote:

>
> Hmm, I wanted to go the other way and remove __asan_mem*.
>
>   
> https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/commit/?h=sched/core-robot&id=79cdfdacd5b8d1ac77e24ccbc178bba0294d0d78

Makes sense. I've put your patch into randconfig tree now, I'll let
you know if that causes other problems.

     Arnd
  

Patch

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 0f67c6a8bc98..e8fb3bf7a2e3 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1248,6 +1248,13 @@  static const char *uaccess_safe_builtin[] = {
 	"clear_user_erms",
 	"clear_user_rep_good",
 	"clear_user_original",
+	"__memset",
+	"__memcpy",
+	"__memmove",
+	"memset_erms",
+	"memcpy_erms",
+	"memset_orig",
+	"memcpy_orig",
 	NULL
 };