linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Andrew Morton <akpm@linux-foundation.org>,
	Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Alexander Potapenko <glider@google.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Andrey Konovalov <andreyknvl@google.com>,
	kasan-dev@googlegroups.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] kasan: add declarations for internal functions
Date: Fri,  5 Jan 2018 10:40:41 +0100	[thread overview]
Message-ID: <20180105094112.2690475-1-arnd@arndb.de> (raw)

A patch got merged that made newly added functions static, leading
to a warning about unused functions as well as a link error when
they are actually used:

mm/kasan/kasan.c:780:7: error: '__asan_set_shadow_f8' defined but not used [-Werror=unused-function]
mm/kasan/kasan.c:791:8: note: in expansion of macro 'DEFINE_ASAN_SET_SHADOW'
mm/kasan/kasan.c:780:7: error: '__asan_set_shadow_f5' defined but not used [-Werror=unused-function]

It turns out the underlying problem is that a lot of the internal
interfaces of the kasan implementation are only ever called from
code generated by the compiler. These don't need any declarations
to work fine, but cause warnings both with sparse and with 'make W=1':

mm/kasan/kasan.c:695:1: warning: symbol '__asan_load1' was not declared. Should it be static?
mm/kasan/kasan.c:695:1: warning: symbol '__asan_store1' was not declared. Should it be static?
mm/kasan/kasan.c:696:1: warning: symbol '__asan_load2' was not declared. Should it be static?
mm/kasan/kasan.c:696:1: warning: symbol '__asan_store2' was not declared. Should it be static?
mm/kasan/kasan.c:697:1: warning: symbol '__asan_load4' was not declared. Should it be static?

This removes the bogus 'static' annotation and adds declarations
for all affected interfaces.

Fixes: mmotm ("kasan: __asan_set_shadow_00 can be static")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 mm/kasan/kasan.c | 12 ++++++------
 mm/kasan/kasan.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index 83a11e7e3700..3fb497d4fbf8 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -783,12 +783,12 @@ EXPORT_SYMBOL(__asan_allocas_unpoison);
 	}								\
 	EXPORT_SYMBOL(__asan_set_shadow_##byte)
 
-static DEFINE_ASAN_SET_SHADOW(00);
-static DEFINE_ASAN_SET_SHADOW(f1);
-static DEFINE_ASAN_SET_SHADOW(f2);
-static DEFINE_ASAN_SET_SHADOW(f3);
-static DEFINE_ASAN_SET_SHADOW(f5);
-static DEFINE_ASAN_SET_SHADOW(f8);
+DEFINE_ASAN_SET_SHADOW(00);
+DEFINE_ASAN_SET_SHADOW(f1);
+DEFINE_ASAN_SET_SHADOW(f2);
+DEFINE_ASAN_SET_SHADOW(f3);
+DEFINE_ASAN_SET_SHADOW(f5);
+DEFINE_ASAN_SET_SHADOW(f8);
 
 #ifdef CONFIG_MEMORY_HOTPLUG
 static int __meminit kasan_mem_notifier(struct notifier_block *nb,
diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
index 2792de927fcd..c12dcfde2ebd 100644
--- a/mm/kasan/kasan.h
+++ b/mm/kasan/kasan.h
@@ -120,4 +120,48 @@ static inline void quarantine_reduce(void) { }
 static inline void quarantine_remove_cache(struct kmem_cache *cache) { }
 #endif
 
+/*
+ * Exported functions for interfaces called from assembly or from generated
+ * code. Declarations here to avoid warning about missing declarations.
+ */
+asmlinkage void kasan_unpoison_task_stack_below(const void *watermark);
+void __asan_register_globals(struct kasan_global *globals, size_t size);
+void __asan_unregister_globals(struct kasan_global *globals, size_t size);
+void __asan_loadN(unsigned long addr, size_t size);
+void __asan_storeN(unsigned long addr, size_t size);
+void __asan_handle_no_return(void);
+void __asan_poison_stack_memory(const void *addr, size_t size);
+void __asan_unpoison_stack_memory(const void *addr, size_t size);
+void __asan_alloca_poison(unsigned long addr, size_t size);
+void __asan_allocas_unpoison(const void *stack_top, const void *stack_bottom);
+
+void __asan_load1(unsigned long addr);
+void __asan_store1(unsigned long addr);
+void __asan_load2(unsigned long addr);
+void __asan_store2(unsigned long addr);
+void __asan_load4(unsigned long addr);
+void __asan_store4(unsigned long addr);
+void __asan_load8(unsigned long addr);
+void __asan_store8(unsigned long addr);
+void __asan_load16(unsigned long addr);
+void __asan_store16(unsigned long addr);
+
+void __asan_load1_noabort(unsigned long addr);
+void __asan_store1_noabort(unsigned long addr);
+void __asan_load2_noabort(unsigned long addr);
+void __asan_store2_noabort(unsigned long addr);
+void __asan_load4_noabort(unsigned long addr);
+void __asan_store4_noabort(unsigned long addr);
+void __asan_load8_noabort(unsigned long addr);
+void __asan_store8_noabort(unsigned long addr);
+void __asan_load16_noabort(unsigned long addr);
+void __asan_store16_noabort(unsigned long addr);
+
+void __asan_set_shadow_00(const void *addr, size_t size);
+void __asan_set_shadow_f1(const void *addr, size_t size);
+void __asan_set_shadow_f2(const void *addr, size_t size);
+void __asan_set_shadow_f3(const void *addr, size_t size);
+void __asan_set_shadow_f5(const void *addr, size_t size);
+void __asan_set_shadow_f8(const void *addr, size_t size);
+
 #endif
-- 
2.9.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2018-01-05  9:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-05  9:40 Arnd Bergmann [this message]
2018-01-05 21:38 ` Dmitry Vyukov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180105094112.2690475-1-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@google.com \
    --cc=aryabinin@virtuozzo.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox