Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5356349imb; Thu, 7 Mar 2019 13:44:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzHzG7N6qfDjw7qBL+Nzgs/rEUf0J5QSWn7WhKXl4cJ6NTCNDI4m/tF/TwAskoWj1MGSyNK X-Received: by 2002:a62:5789:: with SMTP id i9mr14644374pfj.75.1551995045840; Thu, 07 Mar 2019 13:44:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551995045; cv=none; d=google.com; s=arc-20160816; b=O9I2LR8+uGM3b1jyo7c6nAq4pMXtP8IGtZy1jm+fe0FLMzIIcz1ijwpgi+Hcq880ZT YnohAiLPMxGwL4iWN+X7NkabNE84toHsmgCUE5CQW6ndRimJZOwqbky0O+bIjWf/HLSA b6b5o05GUM1SSYWROVnXFsvCZgTH8640UZ0FZuf2D3nlKrqJ48vDqZfRqSY0C6cbEIMF RYqDzvqYLW9LRbfaWa06JeDbAu0V5SeC21PKfIIXH7VIXX+1ZM/Q/VuKUrNJlqmGqfzO QOAyIrG+jTHaJBfqBi5TC0qC48yYDlbDMT9Yk/F+yWSo9krkU0V3iFXH5EzQbICEyR2L XL/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:message-id :in-reply-to:subject:cc:to:from:date; bh=5pk4NIkn1fndNyL8B46mgaUfupURhp7SGiRgvj0dXl0=; b=xVvYDC/nE9wTMN0GG7ifJC4JK4tYkpRajy7NWZDFHNCPh8N1JaCRW6zOS+F7EgCUSt 3K/KxCBOwY7ifao8OUKByQIK3Ulx93a8oZ0wAHbaboV6QvMw4qKYA+DgiF6CVn0sUBjh EI62pPISEA8mVHbDwaVyu+2aT+4lXaHxI20+tsZH6srCCTk9wpTYbmMwevqi1Zu24nIx Qo55WrjhzK+uiL66HKHd1qc21xtxwhpLtJMxTRO6oNT18ekNDYM/0zPXpUoqAH572+do 6puikj6V95IQtMleSz88omwzZQ4BC7IH3zJpYQmj6P3xHMjeVQ++Gc5ItmK2itXZIUd0 9KEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d34si5193574pla.89.2019.03.07.13.43.49; Thu, 07 Mar 2019 13:44:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726319AbfCGVmu (ORCPT + 99 others); Thu, 7 Mar 2019 16:42:50 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:48800 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726217AbfCGVmu (ORCPT ); Thu, 7 Mar 2019 16:42:50 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id 8058222C02; Thu, 7 Mar 2019 16:42:46 -0500 (EST) Date: Fri, 8 Mar 2019 08:43:04 +1100 (AEDT) From: Finn Thain To: Geert Uytterhoeven cc: Andreas Schwab , kbuild test robot , kbuild-all@01.org, linux-m68k , Arnd Bergmann , Linux Kernel Mailing List Subject: Re: [m68k:master 1174/1174] arch/m68k/include/asm/string.h:72:25: warning: '__builtin_memcpy' forming offset 8 is out of the bounds [0, 7] In-Reply-To: Message-ID: References: <201903042049.npxcZzps%fengguang.wu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 7 Mar 2019, Geert Uytterhoeven wrote: > On Thu, Mar 7, 2019 at 3:59 AM Finn Thain wrote: > > On Tue, 5 Mar 2019, Andreas Schwab wrote: > > > On Mar 05 2019, Finn Thain wrote: > > > > > > > interesting that the kernel's strlen implementation in > > > > include/linux/string.h can't achieve this. > > > > > > This implementation is only available if ARCH_HAS_FORTIFY_SOURCE. > > > > > > > I see. Perhaps we could add another definition to that file: > > > > #if !defined(__NO_FORTIFY) && defined(__OPTIMIZE__) && defined(CONFIG_FORTIFY_SOURCE) > > ... > > #else > > __FORTIFY_INLINE __kernel_size_t strlen(const char *p) > > { > > return __builtin_strlen(p); > > } > > #endif > > > > I didn't test that. I've tested it now, it works too. This may be a better solution than defining a strlen macro. diff --git a/include/linux/string.h b/include/linux/string.h index 7927b875f80c..ec9c0a206bd3 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -436,6 +436,13 @@ __FORTIFY_INLINE char *strcpy(char *p, const char *q) return p; } +#else + +__FORTIFY_INLINE __kernel_size_t strlen(const char *p) +{ + return __builtin_strlen(p); +} + #endif /** > But the following patch seems to work... > > > > diff --git a/arch/m68k/include/asm/string.h b/arch/m68k/include/asm/string.h > > index f759d944c449..3cff6b128ed3 100644 > > --- a/arch/m68k/include/asm/string.h > > +++ b/arch/m68k/include/asm/string.h > > @@ -71,4 +71,6 @@ extern void *memset(void *, int, __kernel_size_t); > > extern void *memcpy(void *, const void *, __kernel_size_t); > > #define memcpy(d, s, n) __builtin_memcpy(d, s, n) > > > > +#define strlen(s) __builtin_strlen(s) > > Shouldn't you add > > #define __HAVE_ARCH_STRLEN > > here... > No, the link fails because the compiler still emits some references to strlen(). -- > > + > > #endif /* _M68K_STRING_H_ */ > > diff --git a/lib/string.c b/lib/string.c > > index 38e4ca08e757..fe970f2160e5 100644 > > --- a/lib/string.c > > +++ b/lib/string.c > > @@ -472,6 +472,7 @@ char *strim(char *s) > > EXPORT_SYMBOL(strim); > > > > #ifndef __HAVE_ARCH_STRLEN > > +#undef strlen > > ... so you can drop this change? > > > /** > > * strlen - Find the length of a string > > * @s: The string to be sized > > Gr{oetje,eeting}s, > > Geert > >