From patchwork Wed Feb 1 16:11:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9550039 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9536F60425 for ; Wed, 1 Feb 2017 16:13:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85F2627DF9 for ; Wed, 1 Feb 2017 16:13:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A75E28433; Wed, 1 Feb 2017 16:13:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E10F627DF9 for ; Wed, 1 Feb 2017 16:13:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752303AbdBAQNf (ORCPT ); Wed, 1 Feb 2017 11:13:35 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:51881 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752037AbdBAQNe (ORCPT ); Wed, 1 Feb 2017 11:13:34 -0500 Received: from wuerfel.lan ([78.43.21.235]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0M1kNy-1cJD8A0s3u-00tmMy; Wed, 01 Feb 2017 17:13:16 +0100 From: Arnd Bergmann To: Kees Cook Cc: pageexec@freemail.hu, Emese Revfy , linux-kernel@vger.kernel.org, Josh Triplett , yamada.masahiro@socionext.com, minipli@ld-linux.so, linux@armlinux.org.uk, akpm@linux-foundation.org, jlayton@poochiereds.net, Arnd Bergmann , Robert Moore , Lv Zheng , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, devel@acpica.org, linux-arch@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org Subject: [PATCH] initity: try to improve __nocapture annotations Date: Wed, 1 Feb 2017 17:11:51 +0100 Message-Id: <20170201161311.2050831-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:Mx5LAgBOHlToR5XIWuxJLaYBQ1wUVi/kEpnFFzfDUbVz6tIAscN VuGsFIVjNvVl3Q4AXhXawDHMIWJO2bbRRk4+4XvYnJg22rLWRGNGAci/235Nr7Ns6vlUF0+ ygFi7mpvvGH0jZDpAChQZ7AuCYpH/O4y3j8pYriQG4Qd3jTD1NWELrj9T+5+0GCj/nB6MWT jG+BgXmP4s2839yBWZDIQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:lbr7/RJVfP4=:lYlLWjax7Tjjn6zEc3HMDD TNqFKcA+Obbfd/SgYSvCZoMDy5hLZ9dll2ccy0qy5GMKgbgHd0Z9laJz0zBPBAZ3G5MdhECsE ebShb9BpHfU1otPXLTQu2gj6bu8Y2cZKjLwq9fYH9T2u8OvweOXcFbwj4ue6Y8806cHIKHneP 33UroTZluIu5lRkt/dkcWAt8eeKCTK7geKdyPvYJ4IILnPGv41TA4QbavyoDuRI/SrgH9Vy2U WAysbjeTSO5pM4Xgi71S+709pn1ITKYq/7oOIkAzpehXgTCIchCJGg0nUhOqzLwl6lHR/4ZQ/ aw6rpvshGSALcnacCWNjm+RyT639j6XShZWDgc1FPJiv+BIgg7hB5uaan6c6bL8jyWcrM6exC kySu6Gg/T6ah183xGjW7YNoh/NxYrrGmHMmWdN/Z3PMedZpHRH7Sz+x/ca2WvBxk+4UC5nY1f cqWlXv3xFXp0EUUUt8trHAitm97onfDk86m7VWOcfrSM5HCVcgmNH9kfMsIXfFttZJaNlqQ8V m316W8rl6ixaoYZHOszxH4UOzYHgYAfhOqQfPVrLuLy+ERBj7ulTIjLaSDbdKO5AN5rak6v0v gDP+OWfTb6jlvL5L+0QMcsjMhAwk1JAmjolAEgmTotsIFE/Ou0Z1i/lFW5c69citGWMOSm7Zg 8HQnUuyLDGHiFB3iljhAR6G4L6xu2dzH69Eka2emDLeX+cvm0j/NB6gqxqmMWJb6/KW4= Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are some additional declarations that got missed in the original patch, and some annotated functions that use the pointer is a correct but nonobvious way: mm/kasan/kasan.c: In function 'memmove': mm/kasan/kasan.c:346:7: error: 'memmove' captures its 2 ('src') parameter, please remove it from the nocapture attribute. [-Werror] void *memmove(void *dest, const void *src, size_t len) ^~~~~~~ mm/kasan/kasan.c: In function 'memcpy': mm/kasan/kasan.c:355:7: error: 'memcpy' captures its 2 ('src') parameter, please remove it from the nocapture attribute. [-Werror] void *memcpy(void *dest, const void *src, size_t len) ^~~~~~ drivers/acpi/acpica/utdebug.c: In function 'acpi_debug_print': drivers/acpi/acpica/utdebug.c:158:1: error: 'acpi_debug_print' captures its 3 ('function_name') parameter, please remove it from the nocapture attribute. [-Werror] lib/string.c:893:7: error: 'memchr_inv' captures its 1 ('start') parameter, please remove it from the nocapture attribute. [-Werror] void *memchr_inv(const void *start, int c, size_t bytes) lib/string.c: In function 'strnstr': lib/string.c:832:7: error: 'strnstr' captures its 1 ('s1') parameter, please remove it from the nocapture attribute. [-Werror] char *strnstr(const char *s1, const char *s2, size_t len) ^~~~~~~ lib/string.c:832:7: error: 'strnstr' captures its 2 ('s2') parameter, please remove it from the nocapture attribute. [-Werror] I'm not sure if these are all appropriate fixes, please have a careful look Fixes: c2bc07665495 ("initify: Mark functions with the __nocapture attribute") Signed-off-by: Arnd Bergmann --- drivers/acpi/acpica/utdebug.c | 2 +- include/acpi/acpixf.h | 2 +- include/asm-generic/asm-prototypes.h | 8 ++++---- include/linux/string.h | 2 +- lib/string.c | 2 +- mm/kasan/kasan.c | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c index 044df9b0356e..de3c9cb305a2 100644 --- a/drivers/acpi/acpica/utdebug.c +++ b/drivers/acpi/acpica/utdebug.c @@ -154,7 +154,7 @@ static const char *acpi_ut_trim_function_name(const char *function_name) * ******************************************************************************/ -void ACPI_INTERNAL_VAR_XFACE +void __unverified_nocapture(3) ACPI_INTERNAL_VAR_XFACE acpi_debug_print(u32 requested_debug_level, u32 line_number, const char *function_name, diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 9f4637e9dd92..9644cec5b082 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -946,7 +946,7 @@ ACPI_DBG_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(6) __nocapture(3) const char *module_name, u32 component_id, const char *format, ...)) -ACPI_DBG_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(6) +ACPI_DBG_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(6) __nocapture(3) void ACPI_INTERNAL_VAR_XFACE acpi_debug_print_raw(u32 requested_debug_level, u32 line_number, diff --git a/include/asm-generic/asm-prototypes.h b/include/asm-generic/asm-prototypes.h index 939869c772b1..ffc0dd7e8ed2 100644 --- a/include/asm-generic/asm-prototypes.h +++ b/include/asm-generic/asm-prototypes.h @@ -2,12 +2,12 @@ #undef __memset extern void *__memset(void *, int, __kernel_size_t); #undef __memcpy -extern void *__memcpy(void *, const void *, __kernel_size_t); +extern void *__memcpy(void *, const void *, __kernel_size_t) __nocapture(2); #undef __memmove -extern void *__memmove(void *, const void *, __kernel_size_t); +extern void *__memmove(void *, const void *, __kernel_size_t) __nocapture(2); #undef memset extern void *memset(void *, int, __kernel_size_t); #undef memcpy -extern void *memcpy(void *, const void *, __kernel_size_t); +extern void *memcpy(void *, const void *, __kernel_size_t) __nocapture(2); #undef memmove -extern void *memmove(void *, const void *, __kernel_size_t); +extern void *memmove(void *, const void *, __kernel_size_t) __nocapture(2); diff --git a/include/linux/string.h b/include/linux/string.h index 8b3b97e7b2b0..0ee877593464 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -76,7 +76,7 @@ static inline __must_check char *strstrip(char *str) extern char * strstr(const char *, const char *) __nocapture(-1, 2); #endif #ifndef __HAVE_ARCH_STRNSTR -extern char * strnstr(const char *, const char *, size_t) __nocapture(-1, 2); +extern char * strnstr(const char *, const char *, size_t); #endif #ifndef __HAVE_ARCH_STRLEN extern __kernel_size_t strlen(const char *) __nocapture(1); diff --git a/lib/string.c b/lib/string.c index ed83562a53ae..01151a1a0b61 100644 --- a/lib/string.c +++ b/lib/string.c @@ -870,7 +870,7 @@ void *memchr(const void *s, int c, size_t n) EXPORT_SYMBOL(memchr); #endif -static void *check_bytes8(const u8 *start, u8 value, unsigned int bytes) +static __always_inline void *check_bytes8(const u8 *start, u8 value, unsigned int bytes) { while (bytes) { if (*start != value) diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c index 5f6e09c88d25..ebc02ee1118e 100644 --- a/mm/kasan/kasan.c +++ b/mm/kasan/kasan.c @@ -343,7 +343,7 @@ void *memset(void *addr, int c, size_t len) } #undef memmove -void *memmove(void *dest, const void *src, size_t len) +__unverified_nocapture(2) void *memmove(void *dest, const void *src, size_t len) { check_memory_region((unsigned long)src, len, false, _RET_IP_); check_memory_region((unsigned long)dest, len, true, _RET_IP_); @@ -352,7 +352,7 @@ void *memmove(void *dest, const void *src, size_t len) } #undef memcpy -void *memcpy(void *dest, const void *src, size_t len) +__unverified_nocapture(2) void *memcpy(void *dest, const void *src, size_t len) { check_memory_region((unsigned long)src, len, false, _RET_IP_); check_memory_region((unsigned long)dest, len, true, _RET_IP_);