Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932855AbdGTEll (ORCPT ); Thu, 20 Jul 2017 00:41:41 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:35724 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750751AbdGTElj (ORCPT ); Thu, 20 Jul 2017 00:41:39 -0400 Message-ID: <1500525696.2055.5.camel@gmail.com> Subject: Re: [lkp-robot] [include/linux/string.h] 6974f0c455: kernel_BUG_at_lib/string.c From: Daniel Micay To: Linus Torvalds , kernel test robot , Ananth N Mavinakayanahalli , Anil S Keshavamurthy , Masami Hiramatsu Cc: Kees Cook , Arnd Bergmann , Mark Rutland , Daniel Axtens , Rasmus Villemoes , Andy Shevchenko , Chris Metcalf , Thomas Gleixner , "H. Peter Anvin" , Ingo Molnar , Andrew Morton , LKML , LKP Date: Thu, 20 Jul 2017 00:41:36 -0400 In-Reply-To: References: <20170720014238.GH27396@yexl-desktop> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.24.4 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 925 Lines: 25 > So the fortify_string code has decided that only a single-byte (or > empty) memcpy is ok. > > And that, in turn, seems to be because we're copying from > optprobe_template_entry, which is declared as > > extern __visible kprobe_opcode_t optprobe_template_entry; > > so the fortify code decides it's a single character. > > Does just changing all those things to be declared as arrays fix > things? Yeah, that fixes it because GCC will consider the size of 'char foo[]' unknown (i.e. (size_t)-1 from __builtin_object_size). GCC doesn't know this essentially constant value at compile-time so it wasn't a compile-time error: #define TMPL_END_IDX \ ((long)&optprobe_template_end - (long)&optprobe_template_entry) -fsanitize=object-size works the same way for pointer dereferences so replacing might fix some issues for CONFIG_UBSAN_SANITIZE_ALL. I guess that's way too noisy at the moment thus the !COMPILE_TEST.